Ios 使用推送功能准备ForSegue UITableViewController
我无法将数据从UITableView传递到UIViewController。我正在使用推入式故事板从我的手机转到UIViewController,一切正常。当我在UITableView中选择一个单元格时,它会按下UIViewController,我会得到一个返回按钮,返回UITableView。我的问题是使用PrepareForSegue方法将数据传递到UIViewController。。。这就是我正在做的:Ios 使用推送功能准备ForSegue UITableViewController,ios,uitableview,uiviewcontroller,Ios,Uitableview,Uiviewcontroller,我无法将数据从UITableView传递到UIViewController。我正在使用推入式故事板从我的手机转到UIViewController,一切正常。当我在UITableView中选择一个单元格时,它会按下UIViewController,我会得到一个返回按钮,返回UITableView。我的问题是使用PrepareForSegue方法将数据传递到UIViewController。。。这就是我正在做的: - (void)prepareForSegue:(UIStoryboardSegue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowUserDetailSegue"])
{
UserDetailViewController *userInfo = segue.destinationViewController;
userInfo.myLabel.text = @"Hello World";
NSLog(@"I'm here");
}
}
显示UIViewController时,标签“myLabel”不会更改。知道为什么吗
我以前使用过prepareForSegue,能够传递数据,但不确定我遗漏了什么
另外,xcode显示了所有正确的代码完成情况,并且没有错误
谢谢 在
prepareforsgue
阶段,目标viewController尚未加载其视图,因此userInfo.myLabel
为零
将新属性添加到UserDetailViewController
,改为将其设置为字符串,然后在viewDidLoad
中在标签中设置它