choosePhotoAction

This commit is contained in:
nixzhu
2015-10-16 20:33:26 +08:00
committed by nixzhu
parent d2a95cc91f
commit af59844ef5
2 changed files with 24 additions and 1 deletions
@@ -149,10 +149,29 @@ class ConversationViewController: BaseViewController {
lazy var moreView: ConversationMoreView = ConversationMoreView()
lazy var moreMessageTypesView: MoreMessageTypesView = {
let view = MoreMessageTypesView()
view.pickLocationAction = { [weak self] in
self?.performSegueWithIdentifier("presentPickLocation", sender: nil)
}
view.choosePhotoAction = { [weak self] in
let openCameraRoll: ProposerAction = { [weak self] in
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
if let strongSelf = self {
strongSelf.imagePicker.sourceType = .PhotoLibrary
strongSelf.presentViewController(strongSelf.imagePicker, animated: true, completion: nil)
}
}
}
proposeToAccess(.Photos, agreed: openCameraRoll, rejected: {
self?.alertCanNotAccessCameraRoll()
})
}
return view
}()
@@ -34,9 +34,9 @@ class MoreMessageTypesView: UIView {
}()
var choosePhotoAction: (() -> Void)?
var pickLocationAction: (() -> Void)?
var tableViewBottomConstraint: NSLayoutConstraint?
func showInView(view: UIView) {
@@ -237,6 +237,10 @@ extension MoreMessageTypesView: UITableViewDataSource, UITableViewDelegate {
if let row = Row(rawValue: indexPath.row) {
switch row {
case .PickPhotos:
hideAndDo {
choosePhotoAction?()
}
case .Location:
hideAndDo {
pickLocationAction?()