Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:12:48+00:00 2026-05-29T16:12:48+00:00

I have a question.In my application I have UIActionSheet with 2 buttons one is

  • 0

I have a question.In my application I have UIActionSheet with 2 buttons one is take photo and choose photo from library. My question is how to check whether the device has camera available,If not how can I disable the take photo button from the action sheet.I tried so many things but nothing worked for me. I am adding code below. Please let me know what’s wrong with my code. If I set the take photo button to disable then I am getting an error saying “unrecognized selector sent”.

-(void)gestureRecognizer {
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TapOnImage)];
[recognizer setNumberOfTapsRequired:2];
recognizer.cancelsTouchesInView = NO;
[self.employeeImage addGestureRecognizer:recognizer]; 
self.employeeImage.userInteractionEnabled = YES;
}

-(void)TapOnImage {
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"" delegate:self cancelButtonTitle:@"" destructiveButtonTitle:nil otherButtonTitles:@"Take photo",@"Choose photo", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;

//    NSString *model = [[UIDevice currentDevice]model];
//    NSLog(@"current device:%@",model);

//    if([model isEqualToString:@"iPad1,1"]) {
//    NSString *button = (NSString *)[actionSheet buttonTitleAtIndex:0];
// 
//            UIButton *btn = (UIButton *)button;
//            if ([[btn currentTitle] isEqualToString:@"Take photo"]) {
//                // Do things with button.
//                button.hidden = YES;
//            }

//    }


[actionSheet showFromRect:self.employeeImage.frame inView:self.view animated:YES];

}

- (void)displayImagePicker:(UIImagePickerController *)imagePicker {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    // present from popover
    self.popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];

    [self.popover presentPopoverFromRect:self.employeeImage.frame//popOverRect 
                                  inView:self.view
                permittedArrowDirections:UIPopoverArrowDirectionLeft
                                animated:YES];
 } else  {
    [self presentModalViewController:imagePicker animated:YES];
}
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:  (NSInteger)buttonIndex {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;

if(buttonIndex == 0) {
    if ([UIImagePickerController  isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }
else {
       UIAlertView *alert =  [[UIAlertView alloc]initWithTitle:@"Sorry" message:@"This device doesn't support camera" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles: nil];
       [alert show];

    }
    return;
}
else if(buttonIndex == 1) {
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    }
    else {
        return;
    }
}
else {
    return;

}

[self displayImagePicker:imagePicker];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:12:48+00:00Added an answer on May 29, 2026 at 4:12 pm

    Use this to check if camera is available or not

    [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one question; In my ASP.NET MVC web application have to do certain
I have been developing Android application, and I have one question - ListView uses
I'm using UIActionSheet in one of my applications and I have a question .
I have few question in xcode 4.2 developing.In that i create one application for
Currently we have a Rails application but I have one question regarding the assets
i build a small application with asp.net mvc framework. I have one question. I
I have a question about precompiling ASP.NET web application projects from TeamCity. This is
I have question related to what is done in SMS application is if i'm
I have a question about how to deploy WPF application into a PC without
I have a question in scheduling jobs in web application. If we have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.