我创建了一个包含两个 TableView 的屏幕,在其中我成功调用了 cellForRowAtIndexPath
方法,但现在使用 didSelectRowAtIndexPath
从 tableview 选项导航到另一个页面时遇到问题>。我认为我犯了一些错误,我显然不知道下一步是什么。谁能指导我该怎么做?我用过这个代码-
- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)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 pushViewControllerbj animated:nil];
}
else if (i==1) {
[self.navigationController pushViewControllerbj1 animated:NO];
}
else if (i==2) {
[self.navigationController pushViewControllerbj2 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 pushViewControllerbj animated:nil];
}
else if (i==1) {
[self.navigationController pushViewControllerbj1 animated:NO];
}
else if (i==2) {
[self.navigationController pushViewControllerbj2 animated:NO];
}
}
}
如果你想从表格 View 导航到另一个 View Controller ,不要设置动画:NO。设置动画:是导航。但是如果你设置动画:NO,它肯定不会导航。所以你必须做以下导航的东西。
YourViewController *yourVC = (YourViewController *)[self.storyboard instantiateViewControllerWithIdentifier"StoryBordIdentifier"];
[self.navigationController pushViewController:yourVC animated:YES];
你也可以在这个 didSelectRowAtIndexPath 中使用
[self performSegueWithIdentifier"segueID" sender:self];
与
- (void)prepareForSegueUIStoryboardSegue *)segue senderid)sender
{
YourViewController *vc = segue.destinationViewController;
}
Click Table Row and Go another Page
Segue or didSelectRowAtIndexPath
Making Push Segue when table row is selected
关于ios - 在不同的 tableview 中导航页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374563/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |