Search code examples
xcode4.5zbar-sdk

Can't see IBOUTLETs when using StoryBoard with ZBARReaderView


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.


Solution

  • 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.