uibutton - IOS/Xcode: Name button created in storyboard name so it can be disabled -
i have button created in storyboard taking photo wired action. button says "take photo".
if no camera present, disable button following:
[btnoutlet setenabled:false];
how give button name or otherwise identify can disable it. ios newb here if provide code i.e. put info appreciate it. thank you.
here code working currently.
if (![uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) { //would change alert disable take photo button created in storyboard uialertview *myalertview = [[uialertview alloc] initwithtitle:@"error" message:@"device has no camera" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles: nil]; [myalertview show]; } }
in @interface
, add following code.
@property (nonatomic, strong) iboutlet uibutton *thebutton;
and control-click button in storyboard code you've typed. there should white indicator on left of code indicates button has been linked.
you can disable button such.
[self.thebutton setenabled: no];
Comments
Post a Comment