![](/img/trans.png)
[英]hide modal tab bar controller - from within a view controller IN the tab bar controller
[英]Showing a modal view controller from a tab bar app
首先,我想提醒我,我是iPhone編碼的新手...
我需要從庫中顯示一個ViewController,我知道它是模態的。 我有一個標簽欄應用程序(使用默認的XCode模板創建)。 我需要顯示該viewcontroller,如果它隱藏了標簽欄本身就沒有問題...但是我很無能,甚至都不知道要搜索什么或要閱讀什么...
您可以調用presentModalViewController:animated:以模態顯示另一個UIViewController
。
編輯:如果要顯示模式視圖以響應按鈕觸摸(例如),則應顯示為:
- (IBAction)buttonTouched:(id)sender
{
ModalViewController* controller = [[ModalViewController alloc] init];
[self presentModalViewController:controller animated:YES];
[controller release];
}
然后,當您要關閉模態控制器時,請調用dismissModalViewControllerAnimated:
可以在主視圖控制器或模態控制器上調用它。
我什至不知道該搜索什么,或者閱讀什么...
《 View Controller編程指南》是一個開始的好地方,可以幫助您了解View Controller(包括模態控制器)。 如果這令人困惑,請使用《 iOS應用程序編程指南》全面了解或從頭開始 。
您可以將模式視圖稱為
YourViewController *yvc = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:YES]
[self presentModalViewController:yvc animated:YES];
如果要在任何控制事件(如Button Click)上調用它,可以在IBAction
方法中調用它。
-(IBAction)buttonClicked:(id)sender
{
YourViewController *yvc = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:YES]
[self presentModalViewController:yvc animated:YES];
}
您可以使用self
來調用它。
希望這對您有所幫助。
如果您對此有更多疑問,可以詢問我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.