2015-11-29 44 views
1

我正在创建一个类似我的学校网站的应用程序。我添加了一个按钮,我想使用此代码链接到他们的原始网站。打开链接到Safari使用按钮Swift应用程序崩溃?

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进行编程时相当新,所以我正在寻找所有我可以获得的帮助。

+0

看起来你忘了加上'按钮:'函数来处理按钮事件。 – rmaddy

回答

0

看起来您在连线按钮后,将Button功能重命名为portal

要纠正这一点,在故事板,控制你的按钮 -click,然后通过点击小X删除事件触摸的内心

enter image description here

然后从旁边触摸的内心圆您portal功能拖动。

enter image description here

+0

我刚刚试过你的建议,我仍然收到崩溃错误。 – Chase

+0

它是完全相同的错误还是不同的错误?当你按下按钮时,仍然会说' - [FAQ.RearTableVC Button:]:无法识别的选择器发送到实例'? – vacawama

+0

是的,它仍然会说 - [FAQ.RearTableVC Button:]:无法识别的选择器发送到实例 – Chase

相关问题