在iPhone

时间:2017-01-17 07:45:25

标签: ios objective-c iphone uiviewcontroller uipopovercontroller

我想在UIBarButtonItem

中将视图控制器显示为iPhone中的弹出窗口

我在按钮的操作上编写了以下代码。

-(IBAction)showAvailableCategory:(UIButton *)sender
{
    CategoryPopup *categoryPopupViewController = [[CategoryPopup alloc]init];
    UIPopoverPresentationController *popOverCat  = categoryPopupViewController.popoverPresentationController;
    categoryPopupViewController.preferredContentSize = CGSizeMake(138, 122);
    popOverCat.delegate = self;
    popOverCat.sourceView = sender;
    popOverCat.sourceRect = sender.bounds;
    popOverCat.permittedArrowDirections = UIPopoverArrowDirectionAny;
    [self presentViewController:categoryPopupViewController animated:YES completion:nil];
}

我已在CategoryPopup中将xib设为自由格式,并且我正在实施以下委托方法

-(UIModalPresentationStyle) adaptivePresentationStyleForPresentationController: (UIPresentationController * ) controller
{
    return UIModalPresentationNone;
}

但是它没有弹出窗口,而是全屏,是否有解决方法?

1 个答案:

答案 0 :(得分:0)

您忘记了一个设置,在String manufacturer = "xiaomi"; if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) { //this will open auto start screen where user can enable permission for your app Intent intent = new Intent(); intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")); startActivity(intent); } 初始化后立即添加:

categoryPopupViewController