我正在嘗試使用表格視圖和導航控制器。這是我使用的代碼,如果我使用NIB文件。這段代碼將正常工作,如果我使用NIB文件,但我決定嘗試故事板 -推動故事板中的視圖
- (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];
}
我已經創造了故事板另一個場景和一切設置在那裏。當用戶點擊這個表格視圖中的單元格時,它們將被帶到該場景。這是我寫的代碼,但它是不正確的,我絕望地卡住:( -
- (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都是對
優秀的,它的工作。非常感謝:D – 2012-02-11 22:44:55