0

I'm using the ZBar SDK to read QR codes on iPhone, however I added a button in that view. But the button is not working! Even i tap the button it doesn't go to the action method of that button. Where is the problem actually? Thanks in advance for the help.

-(UIView *)setSettingsButton
{

    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    [view setBackgroundColor:[UIColor clearColor]];
    UIToolbar *myToolBar = [[UIToolbar alloc] init];

    UIBarButtonItem *button=[[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(settingsAction)];

    [myToolBar setItems:[NSArray arrayWithObjects:button,nil]];    

    settingsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 37, 281, 77)];
    [settingsLabel setFont:[UIFont fontWithName:@"Arial-BoldMT" size:16]];
    [settingsLabel setTextAlignment:UITextAlignmentCenter];
    [settingsLabel setBackgroundColor:[UIColor clearColor]];
    [settingsLabel setTextColor:[UIColor blueColor]];
    [settingsLabel setNumberOfLines:1];
    [settingsLabel setText:@"For settings scan admin QR"];
    [view addSubview:settingsLabel];

    settingsLabel.hidden = YES;

    [myToolBar setBarStyle:UIBarStyleDefault];
    CGRect toolBarFrame;
    toolBarFrame = CGRectMake(0, 436, 320, 44);
    [myToolBar setFrame:toolBarFrame];
    [view addSubview:myToolBar];
    return  view;
}
-(void)settingsAction
{

    settingsLabel.hidden = NO;

}
Jitendra
  • 5,055
  • 2
  • 22
  • 42
Leo
  • 135
  • 1
  • 2
  • 18

2 Answers2

0

I can't see where the problem is, but if it helps, I've customized zBar camera views without any problems.

The most likely answer is that a clear views is obscuring the tool-bar view. Here's a library for debugging UIViews: https://github.com/domesticcatsoftware/DCIntrospect

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • BTW: Perhaps rename you 'setSettingsButton' method as 'set' implies a property. – Jasper Blues Jun 12 '13 at 06:00
  • Oh, sorry if I wasn't clear. The suggestion to rename your method was simply a matter of code-style (comment only). The suggestion to fix the problem is to use DCIntrospect to ensure the view is not being obscured by another. – Jasper Blues Jun 12 '13 at 06:34
0

I had the same problem once. It was because my view was too big. Try to change the view's size like UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 380)];, you'll see if it works.

louftansa
  • 515
  • 4
  • 8