[英]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.