【发布时间】:2015-09-10 14:50:18
【问题描述】:
我们有两个UIViewControllers
firstViewController
SecondViewController
.当我们点击the UItableViewCell 时,我们希望它与SecondViewController 保持一致。
我们试过这样
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIStoryboard *storyboard;
destinationController = [[UserDetails alloc] init];
destinationController = (UserDetails *)[storyboard instantiateViewControllerWithIdentifier:@"User"];
destinationController.FriendlyName.text=[usernameFriendlyName objectAtIndex:indexPath.row];
UIBarButtonItem * backButton =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil];
destinationController.navigationItem.backBarButtonItem = backButton;
[self.navigationController pushViewController:destinationController animated:TRUE];
}
请指导我们。我们的代码有什么问题。
【问题讨论】:
-
一件事是您没有正确分配情节提要。尝试使用类方法
storyboardWithName从正确的故事板文件生成故事板。developer.apple.com/library/prerelease/ios/documentation/UIKit/…: -
显然故事板在那里是零
-
为什么要以编程方式执行此操作,只需使用情节提要
-
在尝试编写一些东西之前,您可能应该阅读一些有关 Objective C 的书。您的
storyboard为 nil,因此向其发送消息返回 nil。您还可以实例化destinationController并无缘无故地覆盖它 -
@u.gen 我们需要 didSelectRowAtIndexPath。
标签: ios objective-c uitableview storyboard didselectrowatindexpath