【发布时间】:2015-07-17 14:01:33
【问题描述】:
我正在尝试在注册视图控制器中创建 profilePic。 profilePic 是 UIImageView 类型。我希望能够点击它,以便它立即以 ActionSheet 样式调出照片库。并且还有一个图像框有一个按钮来访问相机。这可能吗?
import UIKit
class SignUpViewController: UIViewController, UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate {
@IBOutlet weak var profilePic: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// PROFILE PICTURE
let tapGesture = UITapGestureRecognizer(target: self, action: "imageTapped:")
profilePic.addGestureRecognizer(tapGesture)
profilePic.userInteractionEnabled = true
}
func imageTapped(gesture:UIGestureRecognizer) {
if let profile1Pic = gesture.view as? UIImageView {
print("Image Tapped")
}
}
【问题讨论】:
标签: xcode swift uiimageview actionsheetpicker