开发者

iPad UIImagePicker Camera Tutorial

I have looking for a complete tutorial on google and stack of a complete example on using the UIImagePicker to get a picture from the camera and a picture from the library or camera roll on the iPad 2.

I have found开发者_JS百科 code snippets saying just add the PopOverController in, but have not been able to implement it successfully.

thanks in advance.


This worked for me.


I do it like this I detect if iPhone or iPad and in the popover where it says (self.album.bounds) is just were you want the popover arrow to appear in this case self.album is the button that fires the below action

-(IBAction)selectPicture:(id)sender {

NSLog(@"Image is not set");

// Create image picker controller
thePicker = [[UIImagePickerController alloc] init];

// Set source to the camer roll;
thePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

// Delegate to self
thePicker.delegate = self;

//Allow editing of image NO
thePicker.allowsEditing = NO;


if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {


[self presentModalViewController:thePicker animated:YES];

}

else{

    popover = [[UIPopoverController alloc]initWithContentViewController:thePicker];
    [popover presentPopoverFromRect:self.album.bounds inView:self.album permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    popover = popover;

}

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜