【问题标题】:problems with didselectrowatindexpathdidselectrowatindexpath 的问题
【发布时间】:2010-04-13 13:24:46
【问题描述】:

我刚刚将我正在制作的应用从导航控制器应用转换为标签栏应用。

但这似乎不再有效,我在做一些傻事吗

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];


    StoryDetailViewController *storyDetailViewController = [[StoryDetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];



    WorldCupAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;

    Story *aStory = [appDelegate.stories objectAtIndex:indexPath.row];
    NSURL *url = [NSURL URLWithString:aStory.picture];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc] initWithData:data];
    storyDetailViewController.downloadedImage = img;


    storyDetailViewController.story = [appDelegate.stories objectAtIndex:indexPath.row];


    [self.navigationController pushViewController:storyDetailViewController animated:NO];

    NSLog(@"view controller pushed");

    [StoryDetailViewController release];
}

【问题讨论】:

  • “视图控制器被推”...被打印...?和 [tableView deselectRowAtIndexPath:indexPath animated:NO];此行应该是函数的最后一行...

标签: iphone objective-c cocoa-touch uinavigationcontroller uitabbarcontroller


【解决方案1】:

问题出在self.navigationController。因为它不再是导航控制器的一部分,所以navigationControllernil。如果您想将新视图推送到层次结构中,可以通过创建一个导航控制器并将该视图作为其根视图控制器,然后将导航控制器的视图添加到选项卡栏来实现。

【讨论】:

    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-10
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多