ios - Can I assign two buttons to a same action or outlet in Xcode 7? -
i have created user interface iphones in 'w compact h any' tab in interface builder. decided make different interface ipad version of app, in 'w regular h regular', when dragging buttons , labels actions , outlets in viewcontroller.h file, replace buttons , labels in other interface.
is there way can preserve both @ same time?
you can click+drag from ibaction
method's little connector circle straight to control in storyboard, if it's been connected 1 (and think can drag storyboard object ibaction
too).
just keep in mind if you're using different classes, you'll want use id
, check class name before stuff it:
- (ibaction)buttonpressed:(id)sender { if ([sender iskindofclass:[uibutton class]]) { // } }
to verify it's connected both, click method circle:
if you're writing swift in xcode 7 or 8, method created use any
type; you'll need change uibutton
in order work:
@ibaction func buttonpressed(sender: uibutton) { // ^ }
Comments
Post a Comment