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 に答える