如何设置UIPopOverController导航栏的标题?

时间:2013-04-01 07:14:01

标签: iphone ios ipad avfoundation uipopovercontroller

我正在研究IPad应用程序。这里它包含PopOver。我需要显示相机并捕获图像。为此我使用的是AVFoundation Framework,其中没有出现默认导航栏。所以我按照以下步骤< / p>

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];

如果你曾经做过这件事,请指导我错在哪里。谢谢你提前

enter image description here

3 个答案:

答案 0 :(得分:-1)

修改如下代码并检查

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];

然后在viewDidLoad CameraViewController方法中编写以下代码

self.navigationItem.title = @"your title";

答案 1 :(得分:-1)

如果没有出现导航栏,请在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呈现并尝试。

答案 2 :(得分:-1)

这可以帮到你...

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];