0
A
回答
3
您可以使用此代碼來實現這一點。這與斯威夫特3和8的XCode
let actionSheet: UIAlertController = UIAlertController.init(title: "Title of the action sheet", message: "Message to display", preferredStyle: .actionSheet)
//Create and add the Cancel action
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .cancel) { action -> Void in
//Just dismiss the action sheet
}
actionSheet.addAction(cancelAction)
//Create and add first option action
let savePictureAction: UIAlertAction = UIAlertAction(title: "Using Camera", style: .default) { action -> Void in
// Write Save Method Here
}
actionSheet.addAction(savePictureAction)
//Create and add a second option action
let sendInMessenger: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
// Write your code to Send In Messenger Here
}
actionSheet.addAction(sendInMessanger)
//Create and add a third option action
let dontLikePhoto: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
// Write your code if you Don't like photo Here
}
actionSheet.addAction(dontLikePhoto)
//Create and add a third option action
let trunOnNotification: UIAlertAction = UIAlertAction(title: "Choose Existing Photo", style: .default) { action -> Void in
// Write your code Turn on Notifications Here
}
actionSheet.addAction(trunOnNotification)
//We need to provide a popover sourceView when using it on iPad
actionSheet.popoverPresentationController?.sourceView = sender as? UIView
//Present the AlertController
self.present(actionSheet, animated: true, completion: nil)
工作請注意,這種方法可從iOS版9
相關問題
- 1. Facebook連接OAuth窗口彈出菜單
- 2. android彈出菜單
- 3. Qt - 彈出菜單
- 4. Autocmd彈出菜單
- 5. 如何在android卡片視圖中創建彈出式菜單
- 6. 使用上下文菜單上的fancybox圖片彈出
- 7. 創建一個點擊圖片時的彈出菜單Android
- 8. CSS和HTML水平彈出菜單 - 右側彈出菜單
- 9. android:彈出菜單,彈出對話框
- 10. 蘋果地圖樣式菜單彈出
- 11. Android彈出菜單不加載菜單
- 12. 長按菜單彈出菜單
- 13. CSS彈出菜單與滾動菜單
- 14. 圖片Javascript彈出
- 15. gtk 3彈出式菜單
- 16. Matlab多選彈出菜單
- 17. 彈出/下拉菜單
- 18. 裝飾彈出菜單
- 19. onitemclicklistener彈出式菜單
- 20. iOS彈出菜單cydia-like
- 21. NSStatusItem與彈出式菜單
- 22. Android彈出式菜單
- 23. Gtkuimanager彈出式子菜單
- 24. 彈出按鈕菜單項
- 25. 建議彈出菜單drracket
- 26. RadGrid編輯彈出菜單
- 27. Xamarin.Forms - 彈出式菜單
- 28. 多彈出式菜單
- 29. 彈出菜單錯誤
- 30. Java GUI彈出式菜單
這與UIAlertControllerStyleActionSheet https://developer.apple的風格本土UIAlertController。 com/reference/uikit/uialertcontroller – Jota
@Jota非常感謝您指出正確的方向。祝你今天愉快! – aznelite89