Σάββατο, 11 Μαΐου 2013

ios - camera create photo simple steps


source code and explanation are from ios Programming The Big Nerd Ranch Guide 3rd Edition
  1. add an UIImageView
  2. in the attributes inspector find the Mode attribute and change it to Aspect Fit (this will resize the image to fit within the bounds of the UIImageView).
  3. add an UIToolbar, click on single button and change Identifier to Camera. 
  4. ctrl+click and drag the photo icon from toolbar at .h file and create an action
  5. on .h file conform with the following protocols 
    <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
  6. put that code on the above action
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
    //if our device has a camera, we want to take a picture, otherwise, we
    //just pick from photo lirary  
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    }
    else
    {
        [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    }
    [imagePicker setDelegate:self];
    
    [self presentViewController:imagePicker animated:YES completion:nil];

to Save the picture we need to implement the 

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου