class VIEwController: UIVIEwController,UITextVIEwDelegate { var textVIEw: UITextVIEw! init(nibname nibnameOrNil: String?,bundle nibBundleOrNil: NSBundle?) { super.init(nibname: nibnameOrNil,bundle: nibBundleOrNil) } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() var wIDthFIEld = self.vIEw.bounds.size.wIDth - 10 var heightFIEld = self.vIEw.bounds.size.height - 69 - 221 var textFIEldString: String! = "" //Set up text fIEld self.textVIEw = UITextVIEw(frame: CGRectMake(5,64,wIDthFIEld,heightFIEld)) self.textVIEw.backgroundcolor = UIcolor.redcolor() self.vIEw.addSubvIEw(self.textVIEw) //Set up the New button var newbuttonString: String! = "New Note" var heightbutton = 568 - heightFIEld - 1000 let newbutton = UIbutton(frame: CGRect(x: 5,y: 5,wIDth: wIDthFIEld,height: 50)) as UIbutton UIbutton.buttonWithType(UIbuttonType.System) newbutton.setTitle(newbuttonString,forState: UIControlState.normal) newbutton.backgroundcolor = UIcolor.redcolor() newbutton.addTarget(self,action: "buttonAction:",forControlEvents: UIControlEvents.touchUpInsIDe) self.vIEw.addSubvIEw(newbutton) } func buttonAction() { println("tapped button") }}
当我按下iOS模拟器中的按钮时,我收到错误“无法识别的选择器发送到实例”。该应用程序打开正常,但按下按钮,它只是崩溃。
func buttonAction(){...
应该
func buttonAction(sender:UIbutton!){ println("tapped button")}
因为newbutton的动作:“buttonAction”,所以。
总结以上是内存溢出为你收集整理的“无法识别的选择器发送到实例”在swift全部内容,希望文章能够帮你解决“无法识别的选择器发送到实例”在swift所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)