UIPopoverPresentationController在iPad iOS 10上被剪切

时间:2016-11-15 10:54:29

标签: ios ipad xcode8 ios10

我试图在弹出窗口控制器中显示一个列表 UIAlertController。适用于iOS 8,9。在iOS 10 ipad上它会被削减。虽然我正在添加动作并验证它正在被添加,但是弹出窗口被削减了。请建议。以下是我的代码 -

UIAlertController * view=   [UIAlertController
                                 alertControllerWithTitle:nil
                                 message:nil
                                 preferredStyle:UIAlertControllerStyleActionSheet];

    if(IS_IPAD) {

            UIPopoverPresentationController *popPresenter = [view
                                                                                                             popoverPresentationController];
            [view setModalPresentationStyle:UIModalPresentationPopover];
            [view setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
                popPresenter.sourceView = self.view;
                popPresenter.sourceRect = CGRectMake(70, 0, self.view.frame.size.width, self.view.frame.size.height);

        popPresenter.barButtonItem = self.navigationItem.leftBarButtonItem;
    }


    // Add Cacel Action
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"إلغاء", @"'Cancel' title for button")
                                                          style:UIAlertActionStyleCancel
                                                        handler:^(UIAlertAction * action) {
        [view dismissViewControllerAnimated:YES completion:nil];
    }];

    [view addAction:cancelAction];
    [self.liveFeed.filter.filtersItems enumerateObjectsUsingBlock:^(DPFilteritem *item, NSUInteger idx, BOOL * _Nonnull stop) {
        if (![item.filterName isKindOfClass:[NSNull class]] && item.filterName.length > 0) {
            UIAlertAction* alertAction = [UIAlertAction
                                          actionWithTitle:item.filterName
                                          style:UIAlertActionStyleDefault
                                          handler:^(UIAlertAction * action)
                                          {
                                              //Do some thing here
                                              NSUInteger index = [[view actions]indexOfObject:action];

                                              [view dismissViewControllerAnimated:YES completion:nil];

                                              [self didSelectAlertItemAtIndex:index];
                                          }];
            [view addAction:alertAction];
        }

    }];

    view.view.tintColor = [UIColor blackColor];
    dispatch_async(dispatch_get_main_queue(), ^ {
        [self presentViewController:view animated:YES completion:^{
                //fix for iOS 9 - known issue in iOS9. You need to set tint color in completion handler.
            view.view.tintColor = [UIColor blackColor];
        }];
    });

iOS 10 - ipad - enter image description here

iOS 9 - ipad - enter image description here

0 个答案:

没有答案