一旦二维码检测到委托将运行,我将使用 zBar SDK,在此委托中我定义了一个 myView 并将其用作相机上的覆盖层,其中包含有关该二维码的信息。在 myView 中有一个按钮,它调用一个方法(testAction),但在这个方法中我无法访问我在委托中定义的任何对象,我如何访问 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
}