У меня была проблема с моим приложением iPhone, работающим на iPad. Я использую вид наложения камеры на первом экране (запускается при запуске приложения), но когда я перехожу на другой экран, поверх него появляется пустое белое пространство. Это появляетсятолько в iPad, на iPhone все прекрасно работает.
Вот прикрепленное изображение, показывающее чистый белый экран
код для наложения камеры
controlView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
controlViewLandscape = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 480, 320)];
controlView1= [[UIView alloc]initWithFrame:CGRectMake(0,170, 420, 480)];
controlViewLandscape1= [[UIView alloc]initWithFrame:CGRectMake(0, 0, 480, 320)];
anImagePickerController = [UIImagePickerController new];
anImagePickerController.view.frame=CGRectMake(0, 0, 320, 480);
anImagePickerController.delegate = self;
anImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
anImagePickerController.cameraDevice=UIImagePickerControllerCameraDeviceFront;
anImagePickerController.showsCameraControls=NO;
anImagePickerController.wantsFullScreenLayout=YES;
anImagePickerController.cameraViewTransform=CGAffineTransformScale(anImagePickerController.cameraViewTransform, 1.16676, 1.34299);
UIButton *startbutton = [UIButton buttonWithType:UIButtonTypeCustom];
[startbutton setImage:[UIImage imageNamed:@"play2.png"] forState:UIControlStateNormal];
startbutton.frame=CGRectMake(130, 390, 55, 55);
[startbutton setTitle:@"Start" forState:UIControlStateNormal];
[startbutton addTarget:self action:@selector(startChat) forControlEvents:UIControlEventTouchUpInside];
anImagePickerController.cameraOverlayView = startbutton;
UIButton *startbutton1 = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton1.frame=CGRectMake(-50, 10, 150, 30);
[startbutton1 setTitle:@"Status:" forState:UIControlStateNormal];
startbutton1.titleLabel.font=[UIFont boldSystemFontOfSize:12];
UIButton *startbutton2 = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton2.frame=CGRectMake(13, 10, 150, 30);
[startbutton2 setTitle:@"Disconnected" forState:UIControlStateNormal];
startbutton2.titleLabel.font=[UIFont boldSystemFontOfSize:12];
//setting button
UIButton *settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
settingBtn.frame=CGRectMake(272, 10, 43, 43);
//[settingBtn setTitle:@"Setting" forState:UIControlStateNormal];
[settingBtn setImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
[settingBtn addTarget:self action:@selector(settingNavigate) forControlEvents:UIControlEventTouchUpInside];
[controlView addSubview:settingBtn];
[controlView addSubview:startbutton2];
[controlView addSubview:startbutton];
[controlView addSubview:startbutton1];
controlView.tag=10;
//for landscape
UIButton *startbuttonl = [UIButton buttonWithType:UIButtonTypeCustom];
[startbuttonl setImage:[UIImage imageNamed:@"play2.png"] forState:UIControlStateNormal];
startbuttonl.frame=CGRectMake(210, 245, 55, 55);
[startbuttonl setTitle:@"Start" forState:UIControlStateNormal];
[startbuttonl addTarget:self action:@selector(startChat) forControlEvents:UIControlEventTouchUpInside];
UIButton *startbutton1l = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton1l.frame=CGRectMake(-60,-8, 150, 30);
[startbutton1l setTitle:@"Status:" forState:UIControlStateNormal];
startbutton1l.titleLabel.font=[UIFont boldSystemFontOfSize:12];
UIButton *startbutton2l = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton2l.frame=CGRectMake(3, -8, 150, 30);
[startbutton2l setTitle:@"Disconnected" forState:UIControlStateNormal];
startbutton2l.titleLabel.font=[UIFont boldSystemFontOfSize:12];
//setting button
UIButton *settingBtnl = [UIButton buttonWithType:UIButtonTypeCustom];
settingBtnl.frame=CGRectMake(420,0, 43, 43);
//[settingBtn setTitle:@"Setting" forState:UIControlStateNormal];
[settingBtnl setImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
[settingBtnl addTarget:self action:@selector(settingNavigate) forControlEvents:UIControlEventTouchUpInside];
[controlViewLandscape addSubview:settingBtnl];
[controlViewLandscape addSubview:startbutton2l];
[controlViewLandscape addSubview:startbuttonl];
[controlViewLandscape addSubview:startbutton1l];
//for landscape left
UIButton *startbuttonlr = [UIButton buttonWithType:UIButtonTypeCustom];
[startbuttonlr setImage:[UIImage imageNamed:@"play2.png"] forState:UIControlStateNormal];
startbuttonlr.frame=CGRectMake(220, 263, 55, 55);
[startbuttonlr setTitle:@"Start" forState:UIControlStateNormal];
[startbuttonlr addTarget:self action:@selector(startChat) forControlEvents:UIControlEventTouchUpInside];
UIButton *startbutton1lr = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton1lr.frame=CGRectMake(-40, 20, 150, 30);
[startbutton1lr setTitle:@"Status:" forState:UIControlStateNormal];
startbutton1lr.titleLabel.font=[UIFont boldSystemFontOfSize:12];
UIButton *startbutton2lr = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton2lr.frame=CGRectMake(23, 20, 150, 30);
[startbutton2lr setTitle:@"Disconnected" forState:UIControlStateNormal];
startbutton2lr.titleLabel.font=[UIFont boldSystemFontOfSize:12];
//setting button
UIButton *settingBtnlr = [UIButton buttonWithType:UIButtonTypeCustom];
settingBtnlr.frame=CGRectMake(440, 20, 43, 43);
//[settingBtn setTitle:@"Setting" forState:UIControlStateNormal];
[settingBtnlr setImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
[settingBtnlr addTarget:self action:@selector(settingNavigate) forControlEvents:UIControlEventTouchUpInside];
[controlViewLandscape1 addSubview:settingBtnlr];
[controlViewLandscape1 addSubview:startbutton2lr];
[controlViewLandscape1 addSubview:startbuttonlr];
[controlViewLandscape1 addSubview:startbutton1lr];
//for portrait down
UIButton *startbuttonlp = [UIButton buttonWithType:UIButtonTypeCustom];
[startbuttonlp setImage:[UIImage imageNamed:@"play2.png"] forState:UIControlStateNormal];
//startbuttonlp.frame=CGRectMake(-50, 210, 55, 55);
startbuttonlp.frame=CGRectMake(50, 385, 55, 55);
[startbuttonlp setTitle:@"Start" forState:UIControlStateNormal];
[startbuttonlp addTarget:self action:@selector(startChat) forControlEvents:UIControlEventTouchUpInside];
UIButton *startbutton1lp = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton1lp.frame=CGRectMake(-130, 0, 150, 30);
[startbutton1lp setTitle:@"Status:" forState:UIControlStateNormal];
startbutton1lp.titleLabel.font=[UIFont boldSystemFontOfSize:12];
UIButton *startbutton2lp = [UIButton buttonWithType:UIButtonTypeCustom];
startbutton2lp.frame=CGRectMake(-66, 0, 150, 30);
[startbutton2lp setTitle:@"Disconnected" forState:UIControlStateNormal];
startbutton2lp.titleLabel.font=[UIFont boldSystemFontOfSize:12];
//setting button
UIButton *settingBtnlp = [UIButton buttonWithType:UIButtonTypeCustom];
settingBtnlp.frame=CGRectMake(192,0, 43, 43);
// settingBtnlp.frame=CGRectMake(92, 70, 43, 43);
[settingBtnlp setImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal];
[settingBtnlp addTarget:self action:@selector(settingNavigate) forControlEvents:UIControlEventTouchUpInside];
[controlView1 addSubview:settingBtnlp];
[controlView1 addSubview:startbutton2lp];
[controlView1 addSubview:startbuttonlp];
[controlView1 addSubview:startbutton1lp];
//to rotate it to landscape
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90) );
landscapeTransform = CGAffineTransformTranslate( landscapeTransform, +90.0, +90.0 );
[controlViewLandscape setTransform:landscapeTransform];
//to rotate it to landscape right
CGAffineTransform landscapeTransformr = CGAffineTransformMakeRotation(degreesToRadian(-90) );
landscapeTransformr = CGAffineTransformTranslate( landscapeTransformr, -90, -90);
[controlViewLandscape1 setTransform:landscapeTransformr];
//to rotate it to portrait right
CGAffineTransform landscapeTransformrp = CGAffineTransformMakeRotation(degreesToRadian(180) );
landscapeTransformrp = CGAffineTransformTranslate( landscapeTransformrp, +180.0, +180.0 );
[controlView1 setTransform:landscapeTransformrp];
controlViewLandscape.tag=20;
controlViewLandscape1.tag=40;
controlView1.tag=30;
//controlView1.hidden=YES;
// controlViewLandscape.hidden = YES;// controlViewLandscape1.hidden = YES;// controlView.hidden = YES;
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if ( ([self interfaceOrientation] == UIInterfaceOrientationPortrait))
{
controlView.hidden = NO;
controlViewLandscape.hidden = YES;
controlView1.hidden = YES;
controlViewLandscape1.hidden = YES;
}
if ( ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft))
{
controlView.hidden = YES;
controlViewLandscape.hidden = YES ;
controlView1.hidden = YES;
controlViewLandscape1.hidden = NO;
}
if ( ([self interfaceOrientation] == UIInterfaceOrientationPortraitUpsideDown ))
{
controlView.hidden = YES;
controlViewLandscape.hidden = YES;
controlView1.hidden = NO;
controlViewLandscape1.hidden =YES;
}
if ( ([self interfaceOrientation] == UIInterfaceOrientationLandscapeRight))
{
controlView.hidden = YES;
controlViewLandscape.hidden = NO;
controlView1.hidden = YES;
controlViewLandscape1.hidden = YES;
}
overlayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 500, 500)];
[overlayView addSubview:controlView];
[overlayView addSubview:controlViewLandscape];
[overlayView addSubview:controlViewLandscape1];
[overlayView addSubview:controlView1];
//anImagePickerController.cameraOverlayView = controlView;
anImagePickerController.cameraOverlayView = overlayView;
[self.navigationController presentModalViewController:anImagePickerController animated:NO];
[anImagePickerController release];