推送视图控制器时,如何使用它传递数据(例如“asdf”:123)?你应该将addObjects添加到NSBundle吗?
解决方法
MyViewController * myVC = [[MyViewController alloc] initWithNibName:nil bundle:nil]; myVC.someProperty = someValue; // Pass your data here [self.navigationController pushViewController:myVC animated:YES];
在你的MyViewController类中:
.H
@interface MyViewController : UIViewController @property (nonatomic,strong) NSString * someProperty; @end
.M
@implementation MyViewController - (void)viewDidLoad { [super viewDidLoad]; // your data has been set // self.someProperty is equal to "some value" }