我創建了一個動作片,但問題是,委託方法是不是叫UIActionSheet與SWIFT
myActionSheet = UIActionSheet()
myActionSheet.addButtonWithTitle("Add event")
myActionSheet.addButtonWithTitle("close")
myActionSheet.cancelButtonIndex = 1
myActionSheet.showInView(self.view)
/// UIActionSheetDelegate
func actionSheet(myActionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int){
if(myActionSheet.tag == 1){
if (buttonIndex == 0){
println("the index is 0")
}
}
}
我用另一種方式,其良好的工作與iOS 8但不適用於iOS 7:
var ActionSheet = UIAlertController(title: "Add View", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet)
ActionSheet.addAction(UIAlertAction(title: "Add event", style: UIAlertActionStyle.Default, handler:nil))
self.presentViewController(ActionSheet, animated: true, completion: nil)
任何想法來解決這個問題?
動作片和警報視圖被折舊在IOS 8和alertController被引入。 – nikhil84
是的,它的棄用,但如果你支持iOS 7的應用程序,那麼alertController將無法正常工作。所以更好地檢查iOS版本併爲iOS 8和iOS 7調用適當的代碼。 –
看看這個答案 - http://stackoverflow.com/questions/27787777/how-to-create-uiactionsheet-actions/27798750#27798750 – Kampai