我正在尝试使用表格 View 和导航 Controller 。如果我使用 NIB 文件,这是我将使用的代码。如果我使用 NIB 文件,这段代码可以正常工作,但我决定尝试 Storyboard -
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (_webViewController == nil) {
self.webViewController = [[[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]] autorelease];
}
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
_webViewController.entry = entry;
[self.navigationController pushViewController:_webViewController animated:YES];
}
我在 Storyboard中创建了另一个场景,并在那里设置了所有内容。当用户单击此 TableView 中的单元格时,他们将被带到该场景。这是我为代码编写的,但它是不正确的,我绝望地卡住了:( -
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"articleView"]){
UINavigationController *navigationController = segue.destinationViewController;
WebViewController *controller = (WebViewController *)navigationController.topViewController;
controller.webView = self;
}
回答 - 答案 2 和 3 都是正确的
最佳答案
两天前我遇到了一个非常相似的问题,用户连续选择了披露附件并想要调用一个 segue。什么对我有用:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"articleView" sender:[self.tableView cellForRowAtIndexPath:indexPath]]; }
只是为了你,我还用 tableView:didSelectRowAtIndexPath: 进行了测试,它可以工作。
享受,
达米安
关于ios - 在 Storyboard 中推送 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9240266/