如何在UIImagePickerController中获取发件人按钮标签/名称/ ID - didFinishPickingMediaWithInfo?

时间:2013-08-07 04:44:43

标签: iphone objective-c xcode

有人可以指导我在下面的方法中获取sender button Tag/Name/ID吗?

-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{

// I Want to get the sender button reference here

}

2 个答案:

答案 0 :(得分:5)

您可以使用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。

答案 1 :(得分: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];
}