如何设置两个viewController之间的接口方法以在导航控制器中传递参数
我创建了基于窗口的应用程序,根控制器作为选项卡栏控制器。一个选项卡栏有导航控制器。
导航控制器的ViewController实现,我正在推Viewcontroller。
我希望将参数从导航控制器的视图控制器传递到推送视图控制器。
我尝试按照以下方法通过。
//ViewController.h
@interface ViewController:UIViewController{
NSString *String;
}
@property(copy, nonatomic)NSString *String;
@end
//ViewController.m
#import "ViewController1.h"
ViewController1 *level1view = [[ViewController alloc]init];
level1view.hideBottomBarWhenPushed = YES;
level1view.theString = String;
[self.navigationController pushViewController:level1view animated:YES];
[level1view release];
//ViewController1.h
NSString *theString;
@property(copy, nonatomic)NSString *theString;
这工作正常。但我想传递多个参数,例如 Integer 和 UITextFiled Values,那么如何做到这一点?
有什么苹果文档可以让我了解这件事吗?
谢谢,
I have created Window based application, root controller as Tab Bar controller. One Tab bar has Navigation controller.
Navigation controller's ViewControlller implementation, I am pushing Viewcontroller.
I am looking to pass parameter from Navigation Controller's View controller to pushed View Controller.
I have tried to pass as per below method.
//ViewController.h
@interface ViewController:UIViewController{
NSString *String;
}
@property(copy, nonatomic)NSString *String;
@end
//ViewController.m
#import "ViewController1.h"
ViewController1 *level1view = [[ViewController alloc]init];
level1view.hideBottomBarWhenPushed = YES;
level1view.theString = String;
[self.navigationController pushViewController:level1view animated:YES];
[level1view release];
//ViewController1.h
NSString *theString;
@property(copy, nonatomic)NSString *theString;
This is working fine. but I want to pass more than one parameter like Integer and UITextFiled Values so how to do that?
Is there any Apple Doc that I can get idea about this?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许使用 NSUserDefaults 代替,就像:
在另一个控制器中:
Maybe use NSUserDefaults instead, just like:
and in the other controller:
你必须像这样一项一项地传递它,但要确保你在
这一行之后全部传递......否则有时它不会反映
所以交换
到
you have to pass it one by one like this only but make sure that you pass it all after
this line... Otherwise sometimes it won't reflect
So interchange
to