I have an app that loads the camera and overlays buttons for fire, reload, and back, as well as a png that animates when the fire and reload buttons are tapped. How would I load the View Controller, which has a .xib with the buttons and image, as an overlay when the camera view loads?
I have the camera view loading when a button on the main screen is tapped, which used to open another View with the buttons and gun image.
Below is what I have done so far, which is loading the camera. I have a separate View Controller named PlayViewController, with an xib for the interface:
-(IBAction)getCameraPicture:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
PlayViewController* overlay = [[PlayViewController alloc] initWithNibName:@"PlayViewController" bundle:nil];
picker.cameraOverlayView = overlay.view;
[picker setDelegate:overlay];
[self presentModalViewController:picker animated:YES];
}
This is in the PlayViewController.m: code
#import "PlayViewController.h"
#import "SoundViewController.h"
@interface PlayViewController ()
@end
@implementation PlayViewControlleriPad...
`
PlayViewController.h:
@interface PlayViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
two array declarations...
}
@property (weak, nonatomic) IBOutlet UIButton *reloadButton;
@property (weak, nonatomic) IBOutlet UIButton *fireButton;
@property (weak, nonatomic) IBOutlet UITextField *ammoField;
@property (weak, nonatomic) IBOutlet UIImageView *type;
@end
Create your view controller and xib as usual, then add this to your code:
The overlay must implement
UIImagePickerControllerDelegateandUINavigationControllerDelegate