2013-08-07 57 views

回答

3

您可以使用picker.view.tag來識別UIImagePickerController類型。每當您調用UIImagePicker時,您都可以設置其視圖的標籤。

我已經使用相同的識別不同的圖像選擇器。

編輯

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; 
imagePickerController.allowsEditing = YES; 
imagePickerController.delegate = self; 
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
imagePickerController.view.tag = 5;//set the tag here 
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editingInfo 
{ 
    NSLog(@"%d",picker.view.tag); 
} 

你會得到變量值wahtever你會設置。

+0

我試過這個選項,但我剛開picker.view.tag值(NULL)。我們是否需要在圖像選擇器按鈕級別聲明某些內容? –

+0

查看編輯答案。 –

0

試試這個

-(IBAction)ownMethod:(id)sender 
{ 
    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; 
    imagePickerController.allowsEditing = YES; 
    imagePickerController.delegate = self; 
    imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    **imagePickerController.view.tag = [sender tag];//set the tag of button to picker tag ** 
    [self presentViewController:imagePickerController animated:YES completion:nil]; 
} 
相關問題