gpt4 book ai didi

Ios,相机在启动时卡住(黑屏)

转载 作者:行者123 更新时间:2023-11-29 02:37:29 27 4
gpt4 key购买 nike

所以我遇到了相机卡住的问题。当它第一次被调用时,它工作得很好。并在按钮上显示我的图像。但是,如果我回到同一个按钮再次调用相机,或者调用相机的页面上的任何其他按钮,它会启动相机但不是黑屏。相机实际上并没有出现。这是我正在使用的代码...帮助会很棒。

func imagePickerController(picker: UIImagePickerController!, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]!) {


let image = info[UIImagePickerControllerOriginalImage] as UIImage
pickedImage = image

if let buttonToSet = buttonToSet {
switch buttonToSet {
case .Button1 :
p1Image = pickedImage
p1ImageButton.setImage(pickedImage, forState: UIControlState.Normal)
case .Button2 :
p2Image = pickedImage
p2ImageButton.setImage(pickedImage, forState: UIControlState.Normal)
case .Button3 :
p3Image = pickedImage
p3ImageButton.setImage(pickedImage, forState: UIControlState.Normal)
case .Button4 :
p4Image = pickedImage
p4ImageButton.setImage(pickedImage, forState: UIControlState.Normal)

}
}


self.dismissViewControllerAnimated(true, completion: nil)
scrollView.setContentOffset(CGPointMake(0, -65), animated: true)


}

func imagePickerControllerDidCancel(picker: UIImagePickerController) {
dismissViewControllerAnimated(true, completion: nil)
scrollView.setContentOffset(CGPointMake(0, -65), animated: true)
}

func promptForSource(){
let actionSheet = UIActionSheet(title: "Image Source", delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Camera", "Photo Roll")

actionSheet.showInView(self.view)

}

func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex != actionSheet.cancelButtonIndex {

if buttonIndex != actionSheet.firstOtherButtonIndex {

promptForCamera()
}
else{
promptForPhotoRoll()
}

}
}

func promptForCamera(){
let controller = UIImagePickerController()
controller.sourceType = UIImagePickerControllerSourceType.Camera
controller.delegate = self
presentViewController(controller, animated: true, completion: nil)
}

func promptForPhotoRoll(){
let controller = UIImagePickerController()
controller.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
controller.delegate = self
presentViewController(controller, animated: true, completion: nil)
}


@IBAction func p1PhotoTapped(sender: AnyObject) {
buttonToSet = .Button1

if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
promptForSource()



}else{
promptForPhotoRoll()
}


}


@IBAction func p2PhotoTapped(sender: AnyObject) {
buttonToSet = .Button2
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
promptForSource()



}else{
promptForPhotoRoll()
}

}


@IBAction func p3PhotoTapped(sender: AnyObject) {
buttonToSet = .Button3
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
promptForSource()



}else{
promptForPhotoRoll()
}

}

@IBAction func p4PhotoTapped(sender: AnyObject) {
buttonToSet = .Button4
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
promptForSource()



}else{
promptForPhotoRoll()
}

}

最佳答案

我发现问题不是代码问题,而是电话问题。关闭手机电源然后重新启动后,我能够解决该问题。

关于Ios,相机在启动时卡住(黑屏),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26182842/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com