UIImagePickerController
在 iOS 9.2 上运行良好,我的 iPhone 内存使用量为 19m。
从 iOS 9.3 开始,我注意到内存使用量增加到 300m 并且应用程序崩溃了。
我的代码:
import UIKit
import MobileCoreServices
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func pick(){
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.mediaTypes = [String(kUTTypeImage)]
imagePicker.allowsEditing = false
self.presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
}
@IBAction func touched(sender: AnyObject) {
pick()
}
}