gpt4 book ai didi

objective-c - iPad、iOS8 和 objective-C 中的 UIAlertController 不显示取消按钮

转载 作者:太空狗 更新时间:2023-10-30 03:25:50 26 4
gpt4 key购买 nike

我正在尝试使用 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];

很遗憾,我无法发布图片,所以如果您需要进一步说明,请告诉我。

最佳答案

在 iOS8 上,取消按钮仅在需要时显示。如果您在 iPhone 上运行该应用程序,它是可见的。如果您在 iPad 上运行该应用程序,则不会显示取消按钮,并且会在用户点击弹出窗口外部时调用取消操作的处理程序(样式:UIAlertActionStyleCancel)。

关于objective-c - iPad、iOS8 和 objective-C 中的 UIAlertController 不显示取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29241812/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com