如何在iPhone屏幕上显示全屏popovercontroller?

时间:2015-01-29 06:36:46

标签: ios objective-c iphone uipopovercontroller

我在导航栏中有UIbarbuttonItem而不是点击按钮效果很好的iPad模拟器,但不能使用iPhone模拟器,因为Popover不支持iPhone。我试图在iPhone屏幕上显示全屏popovercontroller。如何解决这个问题。我添加了我的代码和截图。 提前致谢。 MyCodes;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:nil];
    UIBarButtonItem *cameraItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(doneButtonPressed:)];
    UIBarButtonItem *searchItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:nil];
    UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    NSArray *actionButtonItems = @[shareItem, cameraItem, flexibleItem,searchItem];
    self.navigationItem.rightBarButtonItems = actionButtonItems;



}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)doneButtonPressed:(id)sender
{
    if(![popoverController isPopoverVisible]){
        UIViewController *viewControllerForPopover = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
        popoverController = [[UIPopoverController alloc] initWithContentViewController:viewControllerForPopover];
        popoverController.delegate=self;
        [popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        //popoverController.passthroughViews=[NSArray arrayWithObjects:self.view, nil];
    }
    else{

        [popoverController dismissPopoverAnimated:YES];
    }


}

@interface ViewController : UIViewController<UIPopoverControllerDelegate,UIPopoverPresentationControllerDelegate>{

    UIPopoverController *popoverController;

    CameraViewController *cameraPopOver;
}

我的屏幕; enter image description here

enter image description here

2 个答案:

答案 0 :(得分:0)

我曾经使用KGModal

KGModal是一个简单的控制,允许您在模式弹出窗口中显示任何视图。可以弹出UIView和UIViewController。

答案 1 :(得分:0)

PopoverController无法添加到iPhone,因为此控制器仅适用于iPad,不适用于iOS。要解决您的问题,您可以在那里采取简单的视图或桌面视图,这将显示在栏按钮的点击事件