0
我想創建一個像下面的圖像的例子,而是從圖片庫中選擇圖像或使用相機拍攝圖片(如facebook應用程序)。這個視圖是內置的還是我需要創建一個自定義視圖?彈出式視圖選擇圖像
我想創建一個像下面的圖像的例子,而是從圖片庫中選擇圖像或使用相機拍攝圖片(如facebook應用程序)。這個視圖是內置的還是我需要創建一個自定義視圖?彈出式視圖選擇圖像
所以,你要一個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];
然後在clickedButtonAtIndex做這樣的事情:
- (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];
}
啊,是的!非常感謝,我不知道這是他們所謂的,所以我很難搜索信息。 – mkral