Objective c 以编程方式从XIB-vs-加载覆盖视图,以与UIImagePickerController一起使用
我目前正在为iPhone制作一个摄像头应用程序,我有一个奇怪的现象,我想不出来。我希望你能帮助我理解 在重新创建要传递给UIImagePickerController的覆盖视图时,我已经成功地以编程方式创建了该视图。我所不能做的是在IB中创建带/不带控制器的视图,加载它并成功地将其传递给覆盖指针。如果我通过IB进行操作,则视图不会不透明,并且会完全遮挡相机的视图。我不明白为什么 我在想,当从XIB加载时,可能会指定正常的Objective c 以编程方式从XIB-vs-加载覆盖视图,以与UIImagePickerController一起使用,objective-c,views,camera,overlay,xib,Objective C,Views,Camera,Overlay,Xib,我目前正在为iPhone制作一个摄像头应用程序,我有一个奇怪的现象,我想不出来。我希望你能帮助我理解 在重新创建要传递给UIImagePickerController的覆盖视图时,我已经成功地以编程方式创建了该视图。我所不能做的是在IB中创建带/不带控制器的视图,加载它并成功地将其传递给覆盖指针。如果我通过IB进行操作,则视图不会不透明,并且会完全遮挡相机的视图。我不明白为什么 我在想,当从XIB加载时,可能会指定正常的视图指针,因此会覆盖摄影机的视图,但我有一个示例,其中在控制器类中,视图和覆
视图指针,因此会覆盖摄影机的视图,但我有一个示例,其中在控制器类中,视图和覆盖视图设置为相等。也许加载顺序正在覆盖指针
我们将不胜感激。。。亲切的问候
这个很好用
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// dislodge the MainView from the MainViewController
//
MainViewController *aController = [[MainViewController alloc] init]; //WithNibName:@"MainView" bundle:nil];
aController.sourceType= UIImagePickerControllerSourceTypeCamera;
aController.delegate= aController;
aController.showsCameraControls= NO;
// Programmatically load the MainView from the Nib and assign it as the OverlayView instead
//
NSArray* nibViews= [[NSBundle mainBundle] loadNibNamed:@"MainView" owner:aController options:nil];
UIView* uiView= [nibViews objectAtIndex:0];
uiView.opaque= NO;
uiView.backgroundColor= [UIColor clearColor];
aController.cameraOverlayView= uiView;
self.mainViewController = aController;
[aController release];
mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
[window addSubview:[mainViewController view]];
[window makeKeyAndVisible];
}
这不
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// dislodge the MainView from the MainViewController
//
MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];
aController.sourceType= UIImagePickerControllerSourceTypeCamera;
aController.delegate= aController;
aController.showsCameraControls= NO;
aController.cameraOverlayView= aController.view;
self.mainViewController = aController;
[aController release];
mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
[window addSubview:[mainViewController view]];
[window makeKeyAndVisible];
}