今天在整理專案的時候,無意間看見有一個案子使用了xxx.bundle 的方式,來放專案中用到的圖片檔,由於平常都習慣直接放直接用,倒是第一次看到這種用法。
所以就學習了一下如何建立這個檔案
今天在整理專案的時候,無意間看見有一個案子使用了xxx.bundle 的方式,來放專案中用到的圖片檔,由於平常都習慣直接放直接用,倒是第一次看到這種用法。
所以就學習了一下如何建立這個檔案
剛好遇到有客戶 對應的版本是從 iOS7 開始 但是AlertView 的用法真的是天差地遠啊
if #available(iOS 8.0, *)
{//版本是iOS 8.0 以上
let alertController = UIAlertController(title: "", message: "", preferredStyle: .Alert)
let sendAction = UIAlertAction(title: "OK", style: .Default)
{ (_) in
// 這個按鈕按下去要做的事情
}
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel)
{ (_) in
// 這個按鈕按下去要做的事情
}
alertController.addTextFieldWithConfigurationHandler
{ (textField) in
//增加一個文字輸入框
textField.text = ""//設定輸入框的內容
}
alertController.addAction(cancelAction)//加按鈕
alertController.addAction(sendAction)//加按鈕
self.presentViewController(alertController, animated: true, completion: nil)
}
else
{//版本是iOS7
let alertView = UIAlertView(title: "", message: "", delegate: self, cancelButtonTitle: "OK", otherButtonTitles: "Cancel")
//記得增加 UIAlertViewDelegate 在class 上面
//按鈕按下去的處理就要由 下面這個func 處理
//func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int)
alertView.alertViewStyle = UIAlertViewStyle.PlainTextInput
alertView.tag = self.renamealert
self.renameAlertTextInput = alertView.textFieldAtIndex(0)
self.renameAlertTextInput.text = ""
alertView.show()
}
}
}