我的问题是样本...但我仍然不知道为什么我的视图不会推送到另一个视图...
首先,我在 NSMutableArray 中添加了许多视图
static NSString *titleKey = @"title";
static NSString *viewControllerKey = @"viewController";
- (void)viewDidAppear:(BOOL)animated {
self.menuList = [NSMutableArray array];
FirstView *firstView = [[FirstView alloc]initWithNibName:nil bundle:nil];
[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"FirstView", @""), titleKey,
firstView, viewControllerKey,
nil]];
[FirstView release];
SecondView *secondView = [[SecondView alloc]initWithNibName:nil bundle:nil];
[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"SecondView", @""), titleKey,
secondView, viewControllerKey,
nil]];
[SecondView release];
好的...这就是我在数组中添加视图控制器的方式...
我想当我按下表格视图中的单元格时,它会转到我要显示的视图
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *targetViewController = [[self.menuList objectAtIndex: indexPath.row] objectForKey:viewControllerKey];
targetViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[[self navigationController] pushViewController:targetViewController animated:YES];
}
按下单元格后,什么也没有发生
首先我猜可能是我没有正确设置数组
但是当我记录数组时
里面真的有东西...
这是结果:
Log message: MENU LIST (
{
title = "FirstView";
viewController = "<Firstview: 0x5822500>";
},
{
title = "SecondView";
viewController = "<SecondView: 0x5822870>";
}
)
我不知道为什么程序不起作用......
有没有人有任何想法???
就是这么简单的事情,还是卡在这里3个小时....
非常感谢 :)