Ios 弹出视图以选择图像
我想创建一个如下图所示的示例,但可以从照片库中选择一张图片,或者用相机拍照(如facebook应用程序)。此视图是内置的还是需要创建自定义视图Ios 弹出视图以选择图像,ios,uiview,uiimagepickercontroller,Ios,Uiview,Uiimagepickercontroller,我想创建一个如下图所示的示例,但可以从照片库中选择一张图片,或者用相机拍照(如facebook应用程序)。此视图是内置的还是需要创建自定义视图 那么你想要一份UIActionSheet 这样做: UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"What do you want to do?"
那么你想要一份UIActionSheet 这样做:
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"What do you want to do?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Camera", @"Photos", nil];
[actionSheet showInView:self.view];
[actionSheet release];
然后在ClickedButtonIndex中执行以下操作:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Camera"]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Photos"]) {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:picker animated:YES];
[picker release];
}
你想要一份行动表 这样做:
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"What do you want to do?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Camera", @"Photos", nil];
[actionSheet showInView:self.view];
[actionSheet release];
然后在ClickedButtonIndex中执行以下操作:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Camera"]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Photos"]) {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:picker animated:YES];
[picker release];
}
啊,是的!非常感谢,我不知道他们叫什么,所以我很难找到信息。啊,是的!非常感谢,我不知道他们叫什么,所以我很难找到信息。