【问题标题】:ZBar : custom button in Camera overlay view is not workingZBar:相机叠加视图中的自定义按钮不起作用
【发布时间】:2013-06-12 05:29:37
【问题描述】:

我正在使用 ZBar SDK 在 iPhone 上读取二维码,但是我在该视图中添加了一个按钮。但是按钮不起作用!即使我点击按钮,它也不会转到该按钮的操作方法。问题究竟出在哪里?提前感谢您的帮助。

-(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;

}

【问题讨论】:

    标签: iphone ios zbar-sdk zbar


    【解决方案1】:

    我看不出问题出在哪里,但如果有帮助,我已经自定义了 zBar 相机视图,没有任何问题。

    最有可能的答案是清晰的视图遮盖了工具栏视图。这是一个用于调试 UIViews 的库:https://github.com/domesticcatsoftware/DCIntrospect

    【讨论】:

    • 顺便说一句:也许将您的“setSettingsButton”方法重命名为“set”意味着一个属性。
    • 哦,如果我不清楚,对不起。重命名您的方法的建议只是代码样式的问题(仅限注释)。解决此问题的建议是使用 DCIntrospect 确保视图不会被其他视图遮挡。
    【解决方案2】:

    我曾经遇到过同样的问题。那是因为我的视野太大了。尝试像UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 380)];一样更改视图的大小,你会看到它是否有效。

    【讨论】:

    • 没用!我得到的唯一解决方案是删除工具栏。谢谢顺便说一句。
    猜你喜欢
    • 2019-01-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-17
    • 1970-01-01
    相关资源
    最近更新 更多