Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uibutton Swift 3:如何在ViewDidLoad()函数中显示/隐藏@iAction按钮?_Uibutton_Swift3_Ibaction - Fatal编程技术网

Uibutton Swift 3:如何在ViewDidLoad()函数中显示/隐藏@iAction按钮?

Uibutton Swift 3:如何在ViewDidLoad()函数中显示/隐藏@iAction按钮?,uibutton,swift3,ibaction,Uibutton,Swift3,Ibaction,仅当信息可用时,我才尝试显示/隐藏按钮。例如,我从数据库获取信息,如果字段返回空白,则应隐藏按钮a,否则显示按钮 @IBAction func emailBtn(_ sender: AnyObject) { //blank } viewdidload() if emailURL.characters.count >= 5 { emailBtn.isHidden = false //Giving error Please see the screenshot

仅当信息可用时,我才尝试显示/隐藏按钮。例如,我从数据库获取信息,如果字段返回空白,则应隐藏按钮a,否则显示按钮

@IBAction func emailBtn(_ sender: AnyObject) {
   //blank
}


viewdidload()
if emailURL.characters.count >= 5
    {
        emailBtn.isHidden = false //Giving error Please see the screenshot
    }
    else
    {
        emailBtn.isHidden = true // Giving error Please see the screenshot
    }


}

您试图隐藏@iAction函数。你要做的是隐藏按钮。您需要做的是在代码中创建一个引用该按钮的出口

在情节提要中,Control+将按钮拖动到类中。创建一个出口。这将创建如下内容:

@IBOutlet weak var myButton: UIButton!
您希望在viewDidLoad()中引用该按钮


emailURL是来自数据库的字段值谢谢,但是如果我想在此按钮上执行发送电子邮件操作,是否可能?是的。您不必删除iAction。当你按下按钮时就会发生这种情况。但这就是IBAction的全部内容:动作。这不是物体本身。我试着使用插座,但它一直在崩溃。我创建了一个私有func检查,查看emailURL是否有效,并在视图中调用它,但显示错误输出面板中的错误是objc[14266]:类PLBuildVersion在/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices(0x1239c2998)中实现和/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/privateframes/PhotoLibraryServices.framework/PhotoLibraryServices(0x1237e7d38)。将使用其中一个。哪一个是未定义的。首先,你是否像我提到的那样在故事板中创建了出口?在不创建情节提要引用的情况下,不能仅在代码中引用它。
myButton.isHidden = true