gpt4 book ai didi

ios - 按钮上的 IBAction 功能未触发

转载 作者:搜寻专家 更新时间:2023-11-01 07:27:07 25 4
gpt4 key购买 nike

我在 VC 中有 3 个按钮,都连接到 IBAction 函数。其中两个工作正常,但提交按钮根本不会触发。

我已确保启用了用户交互。我也尝试过添加 sender: AnyObject 作为参数并将函数重新连接到按钮,但仍然没有成功。我也清理了项目。我对发生的事情感到非常困惑。

这是 VC 的样子: enter image description here

连接按钮: enter image description here

按钮的可访问性:

enter image description here

这是每个 IBAction 函数的代码:

@IBAction func captureImage(){
self.saveVideoVar = false
let imageFromSource = UIImagePickerController()
imageFromSource.delegate = self
imageFromSource.allowsEditing = false

//if there is a camera
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
imageFromSource.sourceType = UIImagePickerControllerSourceType.Camera
self.presentViewController(imageFromSource, animated: true){}
}
else{
let title = "Error"
let message = "Could not load camera"

let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
}

}

@IBAction func openImageLibrary(){
self.saveVideoVar = false
let imageFromSource = UIImagePickerController()
imageFromSource.delegate = self
imageFromSource.allowsEditing = false

imageFromSource.sourceType = UIImagePickerControllerSourceType.PhotoLibrary

//presents (loads) the library
self.presentViewController(imageFromSource, animated: true){}
}

//code to submit image and video to amazon S3
@IBAction func submitToS3(){

print("x")


if let img : UIImage = imageView.image! as UIImage{
let path = (NSTemporaryDirectory() as NSString).stringByAppendingPathComponent("image.png")
let imageData: NSData = UIImagePNGRepresentation(img)!
imageData.writeToFile(path as String, atomically: true)

// once the image is saved we can use the path to create a local fileurl
let url:NSURL = NSURL(fileURLWithPath: path as String)
nwyt.uploadS3(url)

}

}

点击提交按钮的控件截图: enter image description here

天哪!我觉得我好笨。有一个我忘记删除的重复屏幕,它看起来完全一样,但不是显示的那个。我将在一个小时内删除它。下面是问题:

enter image description here

最佳答案

通过为按钮设置背景颜色进行检查,以便您了解是否有任何 View 位于按钮上方。

关于ios - 按钮上的 IBAction 功能未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35283759/

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