ios - 在 Storyboard 中推送 View

标签 ios ios5 storyboard

我正在尝试使用表格 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。什么对我有用:

  • 在 Storyboard 中,创建从整个 tableView Controller (不是单元格)到下一个 viewController 的 segue “articleView”。
  • 将以下方法添加到您的 tableViewController:

  • - (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/

    相关文章:

    ios - 推送通知不工作

    view - 如何在 iOS SDK4.2( Storyboard)中使用分段控件更改 View Controller ?需要示例代码

    objective-c - Storyboard View Controller 中的透明背景

    ios - 捕捉操作系统警报的符号断点

    ios - 在 For 循环之后添加具有依赖项的 NSOperation

    objective-c - 如何在不使用 ASIHTTPRequest 的情况下上传多张图片

    iphone - 秒与分钟的换算

    ios - 无法在 UITableView 中定义原型(prototype)单元格

    xcode - 如何解决Xcode 4.3.1中的这个新警告: “Scene is unreachable due to lack of entry points…”?

    iphone - uitableview 的 Storyboard错误