Can't see IBOUTLETs when using StoryBoard with ZBARReaderView

冷暖自知 提交于 2019-12-12 04:32:53

问题


I am trying to write the embedded reader example in ZBar SDK using a story board and not NIB files. I Declare my IBOutlets as so:

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

However when I create a ZBarReaderView View Controller on the main UIView and try click and drag to connect readerView as a referencing outlet, I just can't figure out how to connect it. All I get from the primary ViewController is an option to select view.


回答1:


Add a UIViewController to your Storyboard.

Add a UIView to the UIViewController, now you will have a UINavigationController > UIView > UIView. Give the child UIView the size you expect the reader area to be.

Create a class of type UINavigationController and add the following code to the interface.

@property (nonatomic, strong) ZBarReaderView* readerView;
@property (nonatomic, strong) IBOutlet UIView* skeletonView;

Add the following code to the implementation.

@synthesize skeletonView;
@synthesize readerView;

- (void)viewDidLoad {

    self.readerView = [ZBarReaderView new];
    self.readerView.readerDelegate = self;
    self.readerView.zoom = 1;

    self.readerView.frame = CGRectMake(0, 0, self.skeletonView.frame.size.width, self.skeletonView.frame.size.height);
    [self.skeletonView addSubview:readerView];
    [self.skeletonView sendSubviewToBack:readerView];
    [self.readerView start];

}

Set the UINavigationController class to the class that you have created.

Connect the child UIView to the UIView IBOutlet.

You are read to go and by doing that you don't need to hack anything and you can customize the child view with buttons and messages.



来源:https://stackoverflow.com/questions/12819779/cant-see-iboutlets-when-using-storyboard-with-zbarreaderview

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