不能从iphone上的表视图去详细视图

时间:2010-09-29 06:47:50

标签: iphone

我有表格视图,当用户点击任何一行时,他应该进入下一个视图 但在我的情况下它不起作用,我在这里做错了什么?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        // Navigation logic -- create and push a new view controller
        NSLog(@" push");// is working

        aDetail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];// not wokring




        [self.navigationController pushViewController:aDetail animated:YES];//not working




    }

1 个答案:

答案 0 :(得分:1)

要解决您的问题,请尝试以下方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        // Navigation logic -- create and push a new view controller

        // Don't forget to import DetailViewController.h at the top 
        // and then declare the type down here - see my revision to
        // the beginning of the next line. (I also remove the bundle
        // reference - it's not necessary as far as I know.

        DetailViewController * aDetail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
        [self.navigationController pushViewController:aDetail animated:YES];

       // Memory management - very important!
       // The view is retained by your parent
       // view, so you can and should release 
       // it here to avoid memory leaks.

       [aDetail release]; 
    }