相关疑难解决方法(0)

在iPad,iOS8和Objective-C中,UIAlertController没有显示取消按钮

我正在尝试使用UIAlertController.我需要一个带有两个按钮的弹出框 - "取消"和"删除并退出".但我只能看到"删除并退出"按钮而不是取消按钮.这是代码: -

NSString *confirmText = "Hi";   
UIAlertController *alert = [UIAlertController alertControllerWithTitle:confirmText message:@"" preferredStyle:UIAlertControllerStyleActionSheet];


// Created a deleted action
UIAlertAction *destroyAction = [UIAlertAction actionWithTitle:@"Delete and Sign Out"
                                         style:UIAlertActionStyleDestructive
                                       handler:^(UIAlertAction *action) {
                                           NSLog(@"Delete Action Pressed");
                                           [self signout];
                                       }];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
                                                       style:UIAlertActionStyleCancel
                                                     handler:nil];


[alert.view setTintColor:[UIColor grayColor]];
[alert addAction:cancelAction];
[alert addAction:destroyAction];
[alert setModalPresentationStyle:UIModalPresentationPopover];

UIPopoverPresentationController *popPresenter = [alert popoverPresentationController];
// Set the sourceView.
popPresenter.sourceView = logoutButton;
popPresenter.sourceRect = logoutButton.bounds;
[self presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

不幸的是,我无法发布图片,所以如果您需要更多说明,请告诉我.

objective-c ipad ios8

10
推荐指数
1
解决办法
3053
查看次数

标签 统计

ios8 ×1

ipad ×1

objective-c ×1