我的故事板中有很多视图控制器,我将如何将登录页面数据电子邮件ID传递给我的第三个视图控制器,但我得到了NULL值
这是第一个视图的代码
//in first view i already import my second view below code is in 1st view
//.h
@property (weak, nonatomic) IBOutlet UITextField *emailid;
//.m
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"sendemailid"])
{
UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
UploadImageData *controller = (UploadImageData *)navController.topViewController;
controller.newemailid = self.emailid.text;
NSLog(@"emailid is %@",emailid.text);
}
}
// i already created segue by identifier name "sendemailid"
现在在我的第二个视图中
// in .h
@property (strong, nonatomic) IBOutlet UILabel *emailid;
@property (nonatomic) NSString *newemailid;
// .m in view didload method
self.emailid.text = self.newemailid;
NSLog( @"we get the emailid %@", emailid.text );
我正在获取null值,还有一件事我正在使用NSUSER DEFAULT来保存第一个视图中的emailid。我不知道为什么价值不通过是我遗失的东西请建议...
答案 0 :(得分:1)
我已经完成了这个
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"sendemailid"])
{
UploadImageData *controller=segue.destinationViewController;
controller.newemailid=self.emailid.text;
}
}