在ZBar扫描仪顶部添加叠加层

我正在使用ZBar SDK读取iPhone上的QR码,但是我想添加一些文字到相机/扫描仪视图的底部,这是用户的教学文本。 这是我到目前为止:

UIView *cameraOverlayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; cameraOverlayView.backgroundColor = [UIColor redColor]; UILabel *instructionLabel = [[UILabel alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; [instructionLabel setTextColor:[UIColor grayColor]]; [instructionLabel setBackgroundColor:[UIColor clearColor]]; [instructionLabel setFont:[UIFont fontWithName: @"Trebuchet MS" size: 24.0f]]; [instructionLabel setCenter:cameraOverlayView.center]; [cameraOverlayView addSubview:instructionLabel]; reader.cameraOverlayView = cameraOverlayView; reader.wantsFullScreenLayout = YES; [instructionLabel release]; [cameraOverlayView release]; 

这是完整的课程:

https://gist.github.com/4163761

不幸的是,标签不显示。 ZBar的文件说为了这个目的使用cameraOverlayView,但它似乎并没有工作。

另外需要注意的是,我正在使用Titanium框架,所以这是额外的Titanium类的来源,但我的问题应该是特定于ZBar。

你有没有看到cameraOverlayView? 设置背景颜色为红色或其他:cameraOverlayView.backgroundColor = [UIColor redColor];

如果您根本没有看到cameraOverlayView,那么您可能需要设置阅读器。 showsZBarControls = NO将禁用默认控件并使用您的自定义覆盖。

如果你看到cameraOverlayView,那么标签可能在界限之外。 玩弄原点,并把它放到位置。

顺便说一句我看你不使用ARC,请确保你释放instructionLabel!