【发布时间】:2010-12-04 18:39:15
【问题描述】:
所以我有一个关于 iPhone 视图的问题。我有一个基于 XCode 中的 Tab Bar 模板的应用程序。选项卡视图之一是 TableView。在该表格视图中,当用户选择其中一个单元格时,我希望它加载一个显示更多详细信息的视图。
现在,我有:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SportsAppDelegate *appDelegate = (SportsAppDelegate *)[[UIApplication sharedApplication] delegate];
// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
//Process which one, sets an index
//Show detail
SportsGameView *detail = [[SportsGameView alloc] init];
[detail setMe:index]; //sets the index that tells it which one
[appDelegate.window insertSubview:detail.view atIndex:0];
[self.view removeFromSuperview];
[detail release];
}
在 SportsGameView(我试图在顶部加载的那个)中,我定义了 setMe 来用这些初始化一堆 UILabel。
我可以确认它得到了这些,但不知何故,它实际上并没有出现。我怀疑这与我的.xib 有关。我像往常一样在 SportsGameView 中定义了 IBOutlets,并将它们连接到 Interface Builder 中。
有人知道为什么吗?
对不起,如果这有点混乱。
谢谢!
【问题讨论】:
-
SportsGameView 是 UIView 的子类吗?还是它其实是 UIViewController 的子类?
-
它是 UIViewController 的一个子类,但是别介意,伙计们,我想通了!我不能把它放到 init 中,因为它实际上还没有做任何事情。
-
好的,太好了。但是如果你仍然使用 UIViewControllers,你会发现使用 UINavigationController 会更容易,或者至少使用 pushModalViewController 而不是手动进行视图交换。
-
是的,我想我会这样做。谢谢。
标签: iphone uiview multiple-views