[英]Opening a Link to Safari Using a Button Swift App Crashing?
我正在创建一个行为类似于我的学校网站的应用程序。 我添加了一个按钮,希望使用此代码链接到其原始网站。
import UIKit
class RearTableVC: UITableViewController {
@IBAction func portal(sender: AnyObject) {
let websiteAddress = NSURL(string: "http://www.google.com")
UIApplication.sharedApplication().openURL(websiteAddress!)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
运行该应用程序并单击按钮后,该应用程序将崩溃并留下错误。
2015-11-29 11:10:45.554 FAQ[16888:2329672] -[FAQ.RearTableVC Button:]: unrecognized selector sent to instance 0x7fd0e857c6c0 2015-11-29 11:10:45.560 FAQ[16888:2329672] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FAQ.RearTableVC Button:]: unrecognized selector sent to instance 0x7fd0e857c6c0'
我在使用Swift进行编程方面还很陌生,所以我正在寻找可以得到的所有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.