iPhone 观看问题
我有一个关于 iPhone 上的视图的问题。我有一个基于 XCode 中的选项卡栏模板的应用程序。选项卡视图之一是 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 中定义了 IBOutlet,并将它们连接到 Interface Builder 中。
有人知道为什么吗?
抱歉,如果这有点令人困惑。
谢谢!
So I have a question about views on iPhone. I have an app based on the Tab Bar template in XCode. One of the tab views is a TableView. In that table view, when a user selects one of the cells, I want it to load a view that shows more details about this.
Right now, I have:
- (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];
}
Within the SportsGameView (the one I'm trying to load on top), I have setMe defined to initalize a bunch of UILabels with these.
I can confirm it gets these, but somehow, it doesn't actually show up. I suspect it has something to do with my .xib. I defined IBOutlets in SportsGameView as I normally would, and hooked them up in Interface Builder.
Anyone know why?
Sorry if this was a bit confusing.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能不想使用
insertSubview:... atIndex:0
添加视图,这会将其置于所有其他子视图的“下方”。如果你想把它放在上面,只需使用
addSubview:
。You probably don't want to add the view with
insertSubview:... atIndex:0
, which will put it "below" all other subviews.If you want to put it on top, just use
addSubview:
.