TableView 中的 DetailView 不起作用(IOS)
我从一个具有带有 4 个按钮的 Tabbar 控制器的程序开始。 在其中一个页面上,viewController 中有一个表视图。当我单击该行时,我想推送 DetailView。但什么也没发生,没有错误什么也没有???
有人知道可能出什么问题吗?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the selected item
NSString *selectedItem = [listOfItems objectAtIndex:indexPath.row];
//Initialize the detail view controller and display it.
DetailViewController *myController = [[DetailViewController alloc]
initWithNibName:@"DetailViewController"
bundle:[NSBundle mainBundle]];
myController.title = @"Detail View";
myController.selectedItem = selectedItem;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
}
I'm starting with a program that has a Tabbar controller with 4 buttons.
On one of the pages there is a table view in the viewController. And when I click the row I want to push a DetailView. But nothing happens, no errors nothing???
Anybody an idea what can be wrong?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//Get the selected item
NSString *selectedItem = [listOfItems objectAtIndex:indexPath.row];
//Initialize the detail view controller and display it.
DetailViewController *myController = [[DetailViewController alloc]
initWithNibName:@"DetailViewController"
bundle:[NSBundle mainBundle]];
myController.title = @"Detail View";
myController.selectedItem = selectedItem;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当您的应用程序支持 UINavigation Controller 时,才能导航到另一个视图控制器。如果它在那里,那么其次你的 UITableViewDelegates 不在那里。
为此,您需要
tableView.delegate = self;
或者请详细说明您的问题
Navigation to another View Controller is only can take place when your application supports UINavigation Controller. If It is there then secondly Your UITableViewDelegates are not there.
For this you need to have
tableView.delegate = self;
Or please elaborate your problem more
您确定已设置
UITabelViewDelegate
吗?如果没有,请将UITableView
的委托设置为同时确保您的头文件实现
UITableViewDelegate
协议Are you sure you have set the
UITabelViewDelegate
? If not please set the delegate of theUITableView
asAlso make sure your header file implements the
UITableViewDelegate
protocol