Skip to content

Commit

Permalink
dev:完成用户名的数据传递,在主界面navi显示用户名
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyufeng1991 committed Nov 13, 2015
1 parent 20104cd commit f5d329d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Oncenote/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

@property (strong, nonatomic) UIWindow *window;

@property (strong,nonatomic) NSString *GLOBAL_OBJECTID;//全局的objectID;
@property (strong,nonatomic) NSString *GLOBAL_USERNAME;//全局的用户名;

@end

1 change: 1 addition & 0 deletions Oncenote/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
<outlet property="naviRefreshImage" destination="rE5-wT-sSR" id="b0G-Zr-Vpx"/>
<outlet property="naviSearchImage" destination="ygl-1f-hNd" id="G8n-k4-IKF"/>
<outlet property="naviSettingImage" destination="3Rb-kc-FDO" id="QLp-Ne-snA"/>
<outlet property="naviUsername" destination="1I4-yN-02Z" id="J0E-Pl-888"/>
<outlet property="noteTableView" destination="zVu-dn-TfY" id="S6A-2L-j9i"/>
</connections>
</viewController>
Expand Down
8 changes: 8 additions & 0 deletions Oncenote/LoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "LoginViewController.h"
#import "MainViewController.h"
#import <BmobSDK/Bmob.h>
#import "AppDelegate.h"

@interface LoginViewController ()

Expand All @@ -35,12 +36,19 @@ - (IBAction)loginButtonPressed:(id)sender {
//错误处理
NSLog(@"登录失败");
}else{

//给全局变量设值;
AppDelegate *globalApp = [[UIApplication sharedApplication] delegate];
globalApp.GLOBAL_USERNAME = username;
globalApp.GLOBAL_OBJECTID = user.objectId;

NSLog(@"登录成功,username:%@,password:%@,userId:%@",user.username,user.password,user.objectId);
UIViewController *mainViewController = [[UIViewController alloc] init];
mainViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MainViewController"];
[self presentViewController:mainViewController animated:true completion:^{
//todo;
}];

}

}];
Expand Down
13 changes: 9 additions & 4 deletions Oncenote/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "MainViewController.h"
#import <BmobSDK/Bmob.h>
#import "BmobOperation.h"
#import "AppDelegate.h"

@interface MainViewController ()<UITableViewDataSource,UITableViewDelegate>

Expand All @@ -26,12 +27,10 @@ @interface MainViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong) NSArray *noteTitleArray;
@property(nonatomic,strong) NSArray *noteTimeArray;



@property (weak, nonatomic) IBOutlet UIImageView *naviSettingImage;
@property (weak, nonatomic) IBOutlet UIImageView *naviRefreshImage;
@property (weak, nonatomic) IBOutlet UIImageView *naviSearchImage;

@property (weak, nonatomic) IBOutlet UILabel *naviUsername;

@end

Expand All @@ -40,7 +39,11 @@ @implementation MainViewController
- (void)viewDidLoad {
[super viewDidLoad];

//添加数据
//设置navi中的用户名;
AppDelegate *app = [[UIApplication sharedApplication] delegate];
self.naviUsername.text = app.GLOBAL_USERNAME;

//添加数据;
self.noteTitleArray = [[NSArray alloc] initWithObjects:@"1",@"2",@"3", nil];
self.noteTimeArray = [[NSArray alloc] initWithObjects:@"2015.10.1",@"2011.1.1",@"1991.12.12", nil];

Expand All @@ -49,6 +52,8 @@ - (void)viewDidLoad {
[self.naviRefreshImage addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(naviRefreshButtonPressed:)]];
[self.naviSearchImage addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(naviSearchButtonPressed:)]];



}


Expand Down

0 comments on commit f5d329d

Please sign in to comment.