支持平台:iOS
运行环境:iOS
开发语言:swift
开发工具: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()
}
}