如何在iOS 6.0及更高版本的ZBar条形码阅读器中隐藏信息按钮 [英] How to hide info button in ZBar Bar Code Reader for iOS6.0 and above
本文介绍了如何在iOS 6.0及更高版本的ZBar条形码阅读器中隐藏信息按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在iOS App中使用的是iOS 5.0及更高版本的ZBar条形码阅读器.
I am using ZBar Bar Code Reader for iOS 5.0 and above in my iOS App.
我已使用Camera Interface上的以下代码隐藏了信息按钮.
I have made info button hidden using following code on Camera Interface.
UIView * infoButton= infoButton = [[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
[infoButton setHidden:YES];
但是某种程度上,此代码不适用于iOS6.0及更高版本.
But somehow this code doesn't work for iOS6.0 and Above.
推荐答案
尝试使用此代码,该代码在iOS5.0及更高版本上对我有效.
Try this code, this worked for me on iOS5.0 and above.
float currentVersion = 5.1;
float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
UIView * infoButton;
if (sysVersion > currentVersion)
infoButton = [[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:3];
else
infoButton = [[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:2];
[infoButton setHidden:YES];
说明. 在iOS 6.0中,如果您打印日志.
Explanation. In iOS 6.0, If you print the log.
NSLog(@"%@",[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews]);
输出.
"<_UIToolbarBackground: 0xa0991c0; frame = (0 0; 320 54); autoresize = W; userInteractionEnabled = NO; layer = <CALayer: 0xa0795e0>>",
"<UIImageView: 0xa05d630; frame = (0 -3; 320 3); opaque = NO; autoresize = W+BM; userInteractionEnabled = NO; layer = <CALayer: 0xa05cfb0>>",
"<UIToolbarTextButton: 0xa0a8cc0; frame = (6 0; 60 54); opaque = NO; layer = <CALayer: 0xa0a9460>>",
"<UIButton: 0xa0960e0; frame = (290 18; 18 19); opaque = NO; layer = <CALayer: 0xa0615a0>>
在iOS 5.0中,如果您打印日志.
in iOS 5.0, If you print the log.
NSLog(@"%@",[[[[reader.view.subviews objectAtIndex:1] subviews] objectAtIndex:0] subviews]);
输出.
"<_UIToolbarBackground: 0x8d9df90; frame = (0 0; 320 54); userInteractionEnabled = NO; layer = <CALayer: 0x8dc12c0>> - (null)",
"<UIToolbarTextButton: 0x8de5ae0; frame = (6 0; 60 54); opaque = NO; layer = <CALayer: 0x8de5db0>>",
"<UIButton: 0x8d1b110; frame = (290 18; 18 19); opaque = NO; layer = <CALayer: 0x8dba2b0>>"
因此,对于iOS 6.0及更高版本,它应该是索引3的对象,因为还有一个额外的视图UIImageView .
这篇关于如何在iOS 6.0及更高版本的ZBar条形码阅读器中隐藏信息按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文