一款模仿 iOS8 的iMessage的圖片選擇器
支持平臺:iOS
運行環(huán)境:iOS
開發(fā)語言:swift
開發(fā)工具:Xcode
源碼大小:61.43KB
源碼簡介
這個demo是一款模仿iOS8的iMessage的圖片選擇器。在選項列表視圖中可以滾動顯示待選圖片。
源碼運行截圖
源碼片段
override func viewDidLoad() {
super.viewDidLoad()
let tapRecognizer = UITapGestureRecognizer(target: self, action: "presentImagePickerSheet:")
self.view.addGestureRecognizer(tapRecognizer)
}
// MARK: Other Methods
func presentImagePickerSheet(gestureRecognizer: UITapGestureRecognizer) {
let authorization = PHPhotopbrary.authorizationStatus()
if authorization == .NotDetermined {
PHPhotopbrary.requestAuthorization({ (status) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.presentImagePickerSheet(gestureRecognizer)
})
})
return
}
if authorization == .Authorized {
var sheet = BRNImagePickerSheet()
sheet.numberOfButtons = 3
sheet.delegate = self
sheet.showInView(self.view)
}
else {
let alertView = UIAlertView(title: NSLocapzedString("An error occurred", comment: "An error occurred"), message: NSLocapzedString("BRNImagePickerSheet needs access to the camera roll", comment: "BRNImagePickerSheet needs access to the camera roll"), delegate: nil, cancelButtonTitle: NSLocapzedString("OK", comment: "OK"))
alertView.show()
}
}