Gold Challenge Crosshair: is this solution valid?


#1

Have a question about a solution for the Gold challenge i found:

In the DetailViewController. xib I created a independent view with a UIImageView subview which contains an image of a transparant crosshair. Important is that this view is not a subview of the UIControl which is created during the chapter in the xib.

In detailViewController.h I created a “strong” IBOutlet to this view called overlayView

@class BNRItem, BNRCrosshairView;

@interface DetailViewController : UIViewController <UITextFieldDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>

{
    __weak IBOutlet UITextField *nameField;
    __weak IBOutlet UITextField *serialNumberField;
    __weak IBOutlet UITextField *valueField;
    __weak IBOutlet UILabel *dateLabel;
   IBOutlet BNRCrosshairView *overlayView;
    __weak IBOutlet UIImageView *imageView;
}

In takePicture:(id)sender I use this IBOutlet to set the overlayView of the UIImagePickercontrol.

[code]- (IBAction)takePicture:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
[imagePicker setAllowsEditing:YES];
// If our device has a camera, we want tot ake a picture otherwise we just pick from the photo library

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    //[imagePicker setShowsCameraControls:NO];
    CGRect myCenterframe ;
    myCenterframe.size.width = 320;
    myCenterframe.size.height = 40;
    myCenterframe.origin.x = 0;
    myCenterframe.origin.y = 200;
    [overlayView setFrame:myCenterframe];
    [overlayView setBackgroundColor:[UIColor clearColor]];
   [imagePicker setCameraOverlayView:overlayView];
} else {
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    
}

[imagePicker setDelegate:self];

// Place imagepicker on the screen
[self presentViewController:imagePicker animated:YES completion:nil];

}
[/code]

This all seems to work nice but i can imagine some pitfalls I oversee. The question is if it is acceptable that I use one xib file for two different interface screens?