【发布时间】:2016-11-17 09:24:39
【问题描述】:
我创建了一个包含两个表视图的屏幕,我已成功调用方法cellForRowAtIndexPath,但现在在使用didSelectRowAtIndexPath 从表视图选项导航到另一个页面时遇到了麻烦。我认为我做错了显然不知道下一步是什么。谁能指导我该怎么做?我用过这个代码-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView isEqual:leftTableView]) {
TattooSinglesScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooSinglesScreen"];
EyecatcherScreen *obj1=[self.storyboard instantiateViewControllerWithIdentifier:@"EyecatcherScreen"];
TattooToplist *obj2=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooToplist"];
int i=indexPath.row;
if(i==0){
[self.navigationController pushViewController:obj animated:nil];
}
else if (i==1) {
[self.navigationController pushViewController:obj1 animated:NO];
}
else if (i==2) {
[self.navigationController pushViewController:obj2 animated:NO];
}
}
else {
TattooSinglesScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooSinglesScreen"];
EyecatcherScreen *obj1=[self.storyboard instantiateViewControllerWithIdentifier:@"EyecatcherScreen"];
TattooToplist *obj2=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooToplist"];
int i=indexPath.row;
if(i==0){
[self.navigationController pushViewController:obj animated:nil];
}
else if (i==1) {
[self.navigationController pushViewController:obj1 animated:NO];
}
else if (i==2) {
[self.navigationController pushViewController:obj2 animated:NO];
}
}
}
【问题讨论】:
-
你遇到什么问题?确切地告诉我问题所在。
-
您在 didSelectRowAtIndexpPath 方法的 else 部分完成了相同的代码
-
通过使用此代码,我试图导航到表格视图中的另一个页面,但它不起作用。什么都没有发生
-
是的,我只是在检查它是否工作......稍后我将使用其他页面
-
还是不行:(
标签: ios objective-c uitableview