简体   繁体   中英

Image shows up in iPhone simulator but not ipad - Swift

When I go to select an image from my camera roll and display it in my view it doesn't appear on the Ipad simulator. It works great on the iphone. Here is my code

//--CONTROLS HOW TO PICK THE IMAGE WHEN THIS BUTTON IS CLICKED--\\
@IBAction func chooseImage(sender: AnyObject) {
    var image = UIImagePickerController()
    image.delegate = self
    image.navigationBar.tintColor = UIColor.whiteColor()
    image.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
    image.allowsEditing = false
    self.presentViewController(image, animated: true, completion: nil)
}

//--AFTER THE IMAGED IS PICKED THIS BRINGS BACK THE VIEW--\\
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
    println("Image Selected")
    self.dismissViewControllerAnimated(true, completion: nil)
    imageToPost.image = image
    photoSelected = true
}

Apparently, the UIImageView called imageToPost is not displayed correctly by the iPad simulator. Check your storyboard file and make sure the image view is correctly wired to the outlet.

Also, check any constraints that might push the image view off the screen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM