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

  • SEARCH
  • Home
  • 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 809331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:42:41+00:00 2026-05-15T00:42:41+00:00

I’d like to know how to open the camera inside of a pre-defined frame

  • 0

I’d like to know how to open the camera inside of a pre-defined frame (not the entire screen). When the view loads, I have a box, and inside it, I want to display what the camera sees. I don’t want to snap a picture, just basically use the camera as a viewfinder. I have searched this site and have not yet found what I’m looking for. Please help.

Thanks!
Thomas

Update 1:

Here is what I have tried so far.

1.) I added UIImageView to my xib.
2.) Connect the following outlet to the UIImageView in IB

IBOutlet UIImageView *cameraWindow;

3.) I put the following code in viewWillAppear

-(void)viewWillAppear:(BOOL)animated
{
 [super viewWillAppear:animated];
 UIImagePickerController *picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
 
 picker.sourceType = UIImagePickerControllerSourceTypeCamera;
 [self presentModalViewController:picker animated:YES];

 NSLog(@"viewWillAppear ran");
}

But this method does not run, as evident by the absence of NSLog statement from my console. Please help!

Thanks,
Thomas


Update 2:

OK I got it to run by putting the code in viewDidLoad but my camera still doesn’t show up…any suggestions? Anyone….? I’ve been reading the UIImagePickerController class reference, but am kinda unsure how to make sense of it. I’m still learning iPhone, so it’s a bit of a struggle. Please help!

- (void)viewDidLoad 
{ 
 [super viewDidLoad]; 
 
 // Create a bool variable "camera" and call isSourceTypeAvailable to see if camera exists on device
 BOOL camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
 
 // If there is a camera, then display the world throught the viewfinder
 if(camera)
 { 
  UIImagePickerController *picker = [[UIImagePickerController alloc] init];

  // Since I'm not actually taking a picture, is a delegate function necessary?
  picker.delegate = self;
 
  picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  [self presentModalViewController:picker animated:YES];

  NSLog(@"Camera is available");
 }
 
 // Otherwise, do nothing.
 else 
  NSLog(@"No camera available");
}

Thanks!
Thomas


Update 3:

A-HA! Found this on the Apple Class Reference.

Discussion

The delegate receives notifications
when the user picks an image or movie,
or exits the picker interface. The
delegate also decides when to dismiss
the picker interface, so you must
provide a delegate to use a picker. If
this property is nil, the picker is
dismissed immediately if you try to
show it.

Gonna play around with the delegate now. Then I’m going to read on wtf a delegate is. Backwards? Whatever :-p


Update 4:

The two delegate functions for the class are
– imagePickerController:didFinishPickingMediaWithInfo:
– imagePickerControllerDidCancel:

and since I don’t actually want to pick an image or give the user the option to cancel, I am just defining the methods. They should never run though….I think.

  • 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-15T00:42:42+00:00Added an answer on May 15, 2026 at 12:42 am

    add

    [picker
    dismissModelViewControllerAnimated:YES];

    to delegate method bodies.

    It will dismiss the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have text I am displaying in SIlverlight that is coming from a CMS
I have a JSP page retrieving data and when single or double quotes are
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.