问题
I am trying to show a UIImagePickerController in a UIViewController inside a UITabBarController
SourceType Camera
MediaType kUTTypeMovie
There's no issue presenting the UIImagePickerController, but when dismissed the TabBar moves down half the height, it only happens sometimes... other it dismisses perfectly.
override func viewDidLoad() {
var test: UIButton = UIButton(frame:CGRectMake(140, 200, 100, 100))
test.backgroundColor = UIColor.redColor()
test.addTarget(self, action:"presentCamera", forControlEvents: .TouchDown)
self.view.addSubview(test)
}
func presentCamera(){
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
imag.mediaTypes = [kUTTypeMovie]
imag.delegate = self
imag.sourceType = UIImagePickerControllerSourceType.Camera;
imag.videoQuality = UIImagePickerControllerQualityType.TypeMedium
imag.videoMaximumDuration = 120
imag.allowsEditing = false
self.presentViewController(imag, animated: true, completion:{println("showing")})
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
let library = ALAssetsLibrary()
var videoTemp = info[UIImagePickerControllerMediaURL] as NSURL
videoPath = videoTemp.relativePath
UISaveVideoAtPathToSavedPhotosAlbum(videoPath, self, nil, nil)
picker.dismissViewControllerAnimated(true, completion:{
println("video selected")
})
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(true, completion:{
println("canceled")
})
}
It is also displaying this error:
"Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates."
Here is a video of how the app and the error looks:
https://www.youtube.com/watch?v=o1BgLbZgsfw
回答1:
It was already asked here:
Redbar Noticed when dismissing UIImagePickerController
I also noticed the red status bar when dismissing, solved using this:
you should set "View controller-based status bar appearance" value to YES in the .plist
来源:https://stackoverflow.com/questions/28075126/uiimagepickercontroller-messing-tabbar-frame-when-dismissing