samedi 25 avril 2015

IOS/Xcode: Name button created in storyboard name so it can be disabled


I have a button created in storyboard for taking a photo that is wired to an action. The button says "Take Photo".

If no camera is present, I would like to disable this button with something like following:

[btnOutlet setEnabled:FALSE];

How do I give the button a name or otherwise identify it so that I can disable it. IOS newb here so if you could provide code i.e. where I put this info I would appreciate it. Thank you.

Here is code I am working with currently.

   if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
  //would like to change this alert to just disable the 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];

        }
    }


Aucun commentaire:

Enregistrer un commentaire