iPhone如何更改视图控制器
我需要一个登录视图控制器,登录时进入标签栏控制器,标签栏控制器中的视图应该从登录视图控制器获取数据并更改导航栏(从笔尖拖动)的标题,例如,显示用户名。这样做是这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self.window addSubview:_tabbarController.view];
[self.window addSubview:_loginViewController.view];
[self.window makeKeyAndVisible];
return YES;}
我添加了两个子视图,所以当我删除loginviewcontroller时,根显示在LoginViewController.m中,我这样做是这样的:
-(IBAction)ShangHaiButtonPressed:(id)sender{
[self.view removeFromSuperview];}
那么我如何将登录视图中的值传递给我的标签栏控制器?
I need a login viewcontroller,when log in,entry the tabbar controller,and the view in tabbarcontroller should get the data from the login viewcontroller and change the navigationbar(draged from nib)'s title,for example,show the user's name.I did it like :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self.window addSubview:_tabbarController.view];
[self.window addSubview:_loginViewController.view];
[self.window makeKeyAndVisible];
return YES;}
I add two subview,so when I remove the loginviewcontroller,the root shows,in the LoginViewController.m,I did it like:
-(IBAction)ShangHaiButtonPressed:(id)sender{
[self.view removeFromSuperview];}
so how do i pass the value in login view to my tabbarcontroller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在从超级视图中删除之前,将值传递给 tabbarcontroller
我认为直接删除视图是不合适的。为什么不使用 [_tabbarController PresentModalViewController:_loginViewController]。并在按下按钮后将其关闭。
Before remove from superview pass the value to tabbarcontroller
I think it is not appropriate to remove the view directly. Why not use [_tabbarController presentModalViewController:_loginViewController]. and Dismiss it after button is pressed.