错放:
正确:
我使用以下代码在界面上显示它:
let alert = UIAlertController() // setting buttons self.presentModalVIEwController(alert,animated: true)
有没有另一种方式添加到iPad?还是苹果刚忘了iPad,还是没有实现?
解决方法 您可以使用UIPopoverPresentationController从popover中呈现UIAlertController。在Obj-C:
UIVIEwController *self; // code assumes you're in a vIEw controllerUIbutton *button; // the button you want to show the popup sheet fromUIAlertController *alertController;UIAlertAction *destroyAction;UIAlertAction *otherAction;alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];destroyAction = [UIAlertAction actionWithTitle:@"Remove All Data" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { // do destructive stuff here }];otherAction = [UIAlertAction actionWithTitle:@"Blah" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // do something here }];// note: you can control the order buttons are shown,unlike UIActionSheet[alertController addAction:destroyAction];[alertController addAction:otherAction];[alertController setModalPresentationStyle:UIModalPresentationPopover];UIPopoverPresentationController *popPresenter = [alertController popoverPresentationController];popPresenter.sourceVIEw = button;popPresenter.sourceRect = button.bounds;[self presentVIEwController:alertController animated:YES completion:nil];总结
以上是内存溢出为你收集整理的使用iOS 8在iPad上正确显示UIAlertController全部内容,希望文章能够帮你解决使用iOS 8在iPad上正确显示UIAlertController所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)