ios - Getting error on clicking button in swift -
i newbie ios development , started learning basic stuffs in swift. getting error while try run basic coding practising auto layout. below exceptions occurs while try open dialog on clicking button. posting sample code reference
the exception getting follows:
<nslayoutconstraint:0x79e84ca0 v:[uilabel:0x79e82b40'sadadsfsadfsd']-(90)-[_uilayoutguide:0x79e84610]> make symbolic breakpoint @ uiviewalertforunsatisfiableconstraints catch in debugger. methods in uiconstraintbasedlayoutdebugging category on uiview listed in <uikit/uiview.h> may helpful. 2015-10-01 00:04:18.833 firstdemo[6922:355986] -[firstdemo.viewcontroller showsomething]: unrecognized selector sent instance 0x79e80210 2015-10-01 00:04:18.836 firstdemo[6922:355986] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[firstdemo.viewcontroller showsomething]: unrecognized selector sent instance 0x79e80210' *** first throw call stack: ( 0 corefoundation 0x0025aa94 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x01e5ce02 objc_exception_throw + 50 2 corefoundation 0x00263de3 -[nsobject(nsobject) doesnotrecognizeselector:] + 275 3 corefoundation 0x001a1e3d ___forwarding___ + 1037 4 corefoundation 0x001a1a0e _cf_forwarding_prep_0 + 14 5 libobjc.a.dylib 0x01e710b5 -[nsobject performselector:withobject:withobject:] + 84 6 uikit 0x00a3dc40 -[uiapplication sendaction:to:from:forevent:] + 118 7 uikit 0x00a3dbbf -[uiapplication sendaction:totarget:fromsender:forevent:] + 64 8 uikit 0x00bd38fc -[uicontrol sendaction:to:forevent:] + 79 9 uikit 0x00bd3c7c -[uicontrol _sendactionsforevents:withevent:] + 408 10 uikit 0x00bd2c87 -[uicontrol touchesended:withevent:] + 714 11 uikit 0x00ab4eb8 -[uiwindow _sendtouchesforevent:] + 1095 12 uikit 0x00ab5da4 -[uiwindow sendevent:] + 1118 13 uikit 0x00a5e9b3 -[uiapplication sendevent:] + 266 14 uikit 0x00a35903 _uiapplicationhandleeventqueue + 7327 15 corefoundation 0x00174e7f __cfrunloop_is_calling_out_to_a_source0_perform_function__ + 15 16 corefoundation 0x0016ab0b __cfrunloopdosources0 + 523 17 corefoundation 0x00169f28 __cfrunlooprun + 1032 18 corefoundation 0x00169866 cfrunlooprunspecific + 470 19 corefoundation 0x0016967b cfrunloopruninmode + 123 20 graphicsservices 0x045fa664 gseventrunmodal + 192 21 graphicsservices 0x045fa4a1 gseventrun + 104 22 uikit 0x00a3bcc1 uiapplicationmain + 160 23 firstdemo 0x000784fc main + 140 24 libdyld.dylib 0x028cda21 start + 1 ) libc++abi.dylib: terminating uncaught exception of type nsexception viewcontroller.swift
import uikit class viewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func showmessage(){ let alertcontroller = uialertcontroller(title:"success",message:"awesome done",preferredstyle:uialertcontrollerstyle.alert) alertcontroller.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil)) self.presentviewcontroller(alertcontroller, animated: true, completion: nil) } } please me. kindly text me if question not clear. in advance
so in interface builder created ibaction attached button. looks named 'showsomething' , renamed 'showmessage'.
to fix bug either can change name of method 'showsomething', or you'll have go interface builder, select button, , check outlet connections (the button on upper right that's circle arrow in it).
you'll see old outlet connection showsomething, delete , reconnect button new function 'showmessage'.
Comments
Post a Comment