Here is the class which gives me a modal view of the camera
@interface ViewController : UIViewController <UIImagePickerControllerDelegate> {
UIImagePickerController *cameraView; // camera modal view
BOOL isCameraLoaded;
}
@property (nonatomic, retain) UIImagePickerController *cameraView;
- (IBAction)cameraViewbuttonPressed;
- (void)doSomething;
@end
@implementation ViewController
@synthesize cameraView;
- (void)viewDidLoad {
cameraView = [[UIImagePickerController alloc] init];
cameraView.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraView.cameraOverlayView = cameraOverlayView;
cameraView.delegate = self;
cameraView.allowsEditing = NO;
cameraView.showsCameraControls = NO;
}
- (IBAction)cameraViewbuttonPressed {
[self presentModalViewController:cameraView animated:YES];
isCameraLoaded = YES;
}
- (void)doSomething {
[cameraView takePicture];
if ([cameraView isCameraLoaded]) printf("camera view is laoded");
else {
printf("camera view is NOT loaded");
}
}
- (void)dealloc {
[cameraView release];
[super dealloc];
}
@end
In the app delegate when it's running, I call doSomething:
ViewController *actions = [[ViewController alloc] init];
[actions doSomething];
[actions release];
After I press the camera button, the cameraview loads In the app delegate I call dosomething but nothing happens and I get null for the BOOL which returns "camera view is NOT loaded".
If I call doSomething in the ViewController
class, it works fine, but from another class, it doesn't work.
How can I access the variables in ViewController
class?