iPad UIImagePicker相机教程

时间:2011-07-12 12:26:19

标签: ipad ios4 camera uiimagepickercontroller

我一直在寻找谷歌和完整示例的完整教程,使用UIImagePicker从相机中获取图片,以及从iPad 2上的图书馆或相机胶卷中获取图片。

我发现代码片段只是添加了PopOverController,但是无法成功实现它。

提前感谢。

2 个答案:

答案 0 :(得分:1)

This为我工作。

答案 1 :(得分:0)

我是这样做的我检测到iPhone或iPad以及它所说的popover(self.album.bounds)只是你想要弹出箭头出现在这种情况下self.album是触发它的按钮以下行动

-(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;

}

}