这让我发疯了。我试图在按钮单击时取消隐藏隐藏的UIView,但它无法正常工作。这是代码
import UIKit
class DownloadViewController: UIViewController {
@IBOutlet var activityView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.activityView.hidden = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func downloadAction(sender: AnyObject) {
self.activityView.hidden = false
}
}
请帮帮我。这让我疯了,它没有做这么简单的事情。
答案 0 :(得分:1)
确保您的插座连接到Interface Builder中的正确按钮,尝试通过从IB中的按钮拖动到@IBOutlet代码再次连接它。
答案 1 :(得分:1)
此代码有效,您是否收到错误或按钮没有执行任何操作?
答案 2 :(得分:0)
Swift 3
导入UIKit class DownloadViewController:UIViewController {
@IBOutlet var activityView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.activityView.isHidden = true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func downloadAction(sender: AnyObject) {
self.activityView.isHidden = false
}
}