简体   繁体   中英

Alert Shows Different on Iphone than on Ipad

I want my iphone alert to look like the ipad alert

在此处输入图片说明

code:

    let alertController = UIAlertController(title: "Appcoda", message: "Message in alert dialog", preferredStyle: UIAlertControllerStyle.ActionSheet)

    let deleteAction = UIAlertAction(title: "Delete", style: UIAlertActionStyle.Destructive, handler: {(alert :UIAlertAction) in
        print("Delete button tapped")
    })
    alertController.addAction(deleteAction)

    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {(alert :UIAlertAction) in
        print("OK button tapped")
    })
    alertController.addAction(okAction)

    alertController.popoverPresentationController?.sourceView = view
    alertController.popoverPresentationController?.sourceRect = sender.frame

    presentViewController(alertController, animated: true, completion: nil)

What can I add to the code above to have the iphone alert look like the ipad alert?

Alert are only able to be shown from the bottom of the view/window on the iPhone. Try using an 3rd party alert view. Look here: https://www.cocoacontrols.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM