3

有人可以指导我使用sender button Tag/Name/ID以下方法吗?

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

// I Want to get the sender button reference here

}
4

2 回答 2

6

您可以使用 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);
}

无论您设置什么,您都将获得标签值。

于 2013-08-07T05:10:01.547 回答
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];
}
于 2013-08-07T05:51:09.297 回答