在indexpath选择行不起作用

时间:2011-06-23 18:48:56

标签: iphone objective-c uitableview

大家好我在我的tableview中有不同的部分(超过6个),每个部分都有不同的行。但只有其中一个导致下一个视图控制器 这是代码,但是当我点击它时它不起作用

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger section = [indexPath section];
    NSUInteger row = [indexPath row];
    switch (section) 
    {
        case 5:
        {
            switch (row) 
            {
                case 0:
                {
                    Language_view_controller * language_controller = [Language_view_controller alloc];

                    [self.navigationController pushViewController:language_controller animated:YES];

                    [language_controller release];
                }
                    break;
                    default:
                    break;
            }

        }
        break;
            default:
            break;
    }

}

1 个答案:

答案 0 :(得分:3)

您只是为视图控制器分配内存,您还需要通过执行以下操作来初始化它:

Language_view_controller * language_controller = [[Language_view_controller alloc] initWithNibName:@"Language_view_controller" bundle:nil];
[self.navigationController pushViewController:language_controller animated:YES];
[language_controller release];