【发布时间】:2011-09-23 09:47:32
【问题描述】:
我肯定会失去理智。我已经编写了我认为是相当标准的用法
didSelectRowAtIndexPath: 方法在这里:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
if (row == 0){
BuildingDescriptionViewController *buildingDescriptionViewController = [[BuildingDescriptionViewController alloc] initWithNibName:@"BuildingDescriptionViewController" bundle:[NSBundle mainBundle]];
NSLog(@"self.navigationController0 is %@", self.navigationController ? @"not nil" : @"nil");
[self.navigationController pushViewController:buildingDescriptionViewController animated:YES];
[buildingDescriptionViewController release];
}
else if (row == 1){
PostCommentViewController *buildingCommentViewController = [[PostCommentViewController alloc] init];
NSLog(@"self.navigationController1 is %@", self.navigationController ? @"not nil" : @"nil");
[self.navigationController pushViewController:buildingCommentViewController animated:YES];
[buildingCommentViewController release];
}
}
NSLog 通知 navigationController 不是 nil,但没有其他任何事情发生。 viewController 都没有出现。实际上,只是发生了 NSLog。我缺少一些深奥的用法吗?我也试过 [self presentModalViewController:buildingDescriptionViewController animated:YES];什么也没发生。我真的可以使用一些帮助。 谢谢。
更新: 下面根据 Sailesh 的建议输出
2011-06-27 18:02:56.370 something[16331:207] buildingdescriptionviewcontrollerinit 2011-06-27 18:02:56.370 东西[16331:207] 推送前的视图控制器:( “BuildingProfileViewController:0x7e89680” )
2011-06-27 18:02:56.370 something[16331:207] 推送后的视图控制器:( "BuildingProfileViewController: 0x7e89680>", “建筑描述视图控制器:0x7e73d30” )
2011-06-27 18:03:15.843 something[16331:207] buildingdescriptionviewcontrollerinit
2011-06-27 18:03:15.844 something[16331:207] 推送前的视图控制器:( "BuildingProfileViewController: 0x7e89680", “建筑描述视图控制器:0x7e73d30” )
2011-06-27 18:03:15.844 something[16331:207] 推送后的视图控制器:( “BuildingProfileViewController:0x7e89680” “建筑描述视图控制器:0x7e73d30” “建筑描述视图控制器:0xcc2c8e0” )
【问题讨论】:
-
你确定 buildingDescriptionViewController/buildingCommentViewController 不是 nil 吗?
-
buildingDescriptionViewController 不是零,但即使它是不会有一些结果?令人困惑。
-
可能我的情况不太清楚。当我选择行时,NSLog 会显示正确的行,但这是唯一的结果。没有其他事情发生。它不会爆炸。它只是不会推送到下一个 viewController。
标签: iphone objective-c ios cocoa-touch uinavigationcontroller