[英]How to set title to UIPopOverController's Navigation Bar?
我正在使用iPad應用程序,它由PopOver組成。我需要顯示相機並捕獲圖像。為此,我正在使用AVFoundation Framework,其中沒有出現默認導航欄。因此,我按照以下步驟進行操作
cameraVC = [[CameraViewController alloc] initWithNibName:@"CameraViewController" bundle:nil ];
cameraVC.navigationItem.title = @"Take Photo";
UINavigationController *naviCon = [[UINavigationController alloc]initWithRootViewController:cameraVC];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:naviCon];
self.popoverController = popover;
self.popoverController.delegate = self;
self.popover.popoverContentSize = CGSizeMake(450, 350);
[self.popoverController presentPopoverFromRect:CGRectMake(295, 40, 0, 0) inView:appDelegate.splitview.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
如果您曾經嘗試過,請告訴我哪里錯了。
如下修改代碼並檢查
cameraVC = [[CameraViewController alloc] init];
UINavigationController *naviCon = [[UINavigationController alloc]initWithRootViewController:cameraVC];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:naviCon];
[self.presentPopOverController presentPopoverFromBarButtonItem:self.yourBarButton permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
然后在CameraViewController
viewDidLoad
方法中編寫以下代碼
self.navigationItem.title = @"your title";
如果沒有出現導航欄,請在cameraViewController中添加UIToolBar以執行所需的功能。
我在項目中執行了類似的操作,並在popOVer中獲得了NavigationBar。
PageSelectorViewController *pageSelector=[[PageSelectorViewController alloc]initWithStyle:UITableViewStylePlain] ;
UINavigationController *navControl=[[UINavigationController alloc]initWithRootViewController:pageSelector];
self.selectedPagesPopOver=[[UIPopoverController alloc]initWithContentViewController:navControl];
[self.selectedPagesPopOver presentPopoverFromBarButtonItem:showPages permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
我想從自定義矩形中呈現popOver是問題,請嘗試從BarButton呈現,然后嘗試。
這可以幫助您...
MyController* controller = [[MyController alloc] initWithNibName:@"MyController" bundle:nil];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:controller];
controller.title = @"My Title"; //or you can put this line in MyController class viewDidLoad method as self.title = @"My Title";
controller.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0);
_myPopover = [[UIPopoverController alloc] initWithContentViewController:navController];
[_myPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.