-1

デリゲートが実行されることを qr コードが検出したら、zBar SDK を使用しています。このデリゲート内で myView を定義し、その qr コードに関する情報をカメラのオーバーレイとして使用しました。myView 内にはメソッド (testAction) を呼び出すボタンがありますが、このメソッド内ではデリゲートで定義したオブジェクトにアクセスできません。

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

    UIView *myView;
    CGRect frame= CGRectMake(0, 0, 320, 428);
    myView=[[UIView alloc] initWithFrame:frame];
    myView.backgroundColor=[UIColor greenColor];
    myView.alpha=0.7;


    CGRect labelFrame = CGRectMake( 0, 0, 500, 30 );
    UILabel* myLabel = [[UILabel alloc] initWithFrame: labelFrame];

    [myLabel setTextColor: [UIColor orangeColor]];

     NSString *combined = [NSString stringWithFormat:@"%@%@", @"Title: ", symbol.data];
    myLabel.text=combined;


    UIButton * myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    myButton.frame = CGRectMake(10, 50, 100, 50);
    myButton.tag = 121;
    [myButton setTitle:@"Do Something" forState:UIControlStateNormal];
    [myButton setBackgroundImage:nil forState:UIControlStateNormal];
    [myButton addTarget:self action:@selector(testAction:) forControlEvents:UIControlEventTouchUpInside];

    //[button setBackgroundColor:red];



    [myView addSubview: myLabel];
    [myView addSubview: myButton];

    reader.cameraOverlayView=myView;


}

- (void)testAction: (id)sender{
    //my issue is here
}
4

1 に答える 1