簡體   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