ZBarReadview with custom size from StoryBoard,but when it's called,it's size is not I set

给你一囗甜甜゛ 提交于 2019-12-11 05:53:13

问题


i've got a ZBarReaderView created from storyboard with 300*90 px which is shown as roughly 200*400 px because ZBarReaderView doesn't take it's size too serious...

I Declare my IBOutlets as so:

@interface MYQViewController : UIViewController < ZBarReaderViewDelegate >
{
    ZBarReaderView *readerView;
    ZBarCameraSimulator *cameraSim;
    UITextView *resultText;
}
@property (strong, nonatomic) IBOutlet ZBarReaderView *readerView;
@property (strong, nonatomic) IBOutlet UITextView *resultText;
@end

in the viewDidLoad

-(void) viewDidLoad
{
 readerView.readerDelegate = self;
 readerView.zoom=1;
 if(TAGET_IPONE_SIMULATOR)
{
 cameraSim=[[ZBarCameraSimulator alloc] initWithViewController:self];
 cameraSim.readerView=readerView;
}
}

-(void)Scan
{
    if(readerView.hidden)
    {
         [readerView start];
         readerView.hidden = NO;
         resultText.text=EMPTY_STRING;
    }
    else
    {
         [readerView stop];
         readerView.hidden = YES;
         //OTHER CODES        
    }
}

-(void) readerView:(ZBarReaderView *)readerView didReadSymbols:(ZBarSymbolSet * )symbolsfromImage:(UIImage *)image
{
    for (ZBarSymol *sym in symbols)
    {
        self.resultText.text=sym.data;
        break;
    }
}

回答1:


I had a similar problem to solve. I created an UIView in Storyboard and assigned ZBarReaderView as class to it. When ZBarViewReaderView was started it extended my view by far.

I found the solution while comparing the example code (EmbeddedReader) to my code. It was pretty simple:

In Storyboard or Interface Builder, if your view is selected, you have to check the "Clip Subviews" checkmark. Now the camera image stays exactly where it should.

Here is a screenshot of the properties in Storyboard:

Hope I could help.



来源:https://stackoverflow.com/questions/12906557/zbarreadview-with-custom-size-from-storyboard-but-when-its-called-its-size-is

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!