繁体   English   中英

如何使用xib插入子视图?

[英]How to insert a subview with xib?

有多个观点,我很困惑。 我只是想在主视图上有一个按钮来激活一个新视图,而新视图又有一个(x)按钮,可以返回到主视图。 对于我的生活,我无法弄清楚如何使用两个单独的.xib文件来做到这一点。 怎么可能这样做?

谢谢!

将实用程序应用程序用作模板可能最简单。

从那里,您可以看到如何加载视图控制器和笔尖以便显示新视图,然后是如何退出它。

我实际上是通过这种方式解决的:

 NewViewController *new = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
new.delegate = self;
new.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:new animated:YES];
[new release];

您正在使用导航控制器,对吗?

在与主视图上的按钮点击关联的IBAction上,将

NewViewController *newView = ... // [alloc - init your view here if you haven't already]
[self.navigationController pushViewController:newView animated:YES];

在newView上的按钮上,

[self.navigationController popViewControllerAnimated:YES]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM