Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

printf

macrumors regular
Original poster
Aug 27, 2008
105
0
i have some sample code of adding a UIImagePickerController to the subview of a window within the AppDelegate (which works fine), but i want to perform this action for a view within my view controller. All the code I see online is the same as mine, but theirs doesn't explicitely call [view addSubview:imagePicker.view]. anyway, when i run the following it compiles and runs fine, but all i see is a white screen with a blue bar at the top, so i'm clearly doing something wrong.

ViewController.h:
Code:
@interface ViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>{
	UIView* uiView;
	UIImageView *imageView;	
	UIImagePickerController *imagePicker;
}

ViewController.m:
Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
	
	imagePicker = [[UIImagePickerController alloc] init]; 
	imagePicker.allowsImageEditing = YES;
	imagePicker.delegate = self; 
	imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
	
	[self.view addSubview:imagePicker.view];
}

any ideas?
 
nope, no luck. it did produce a slightly different result (a completely white screen with no blue bar), but no image picker. any other ideas? could someone try that code and see if it works for them?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.