2011-09-13 65 views
2

我的iPhone應用程序在iPad上運行時遇到了問題。我在第一個屏幕中使用了相機覆蓋視圖(應用程序啓動時啓動),但是當我導航到其他屏幕時,它的頂部空間。這隻出現在iPad上,iPhone上的所有作品都很棒。iPhone應用程序運行在ipad上的問題

在這裏被安裝圖像顯示空白屏幕
enter image description here

相機重疊視圖代碼

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]; 

回答

0

解決,

使用下面的行顯示在狀態欄

[[UIApplication sharedApplication]setStatusBarHidden:NO]; 

而且它顯示一個黑條,而不是一個空格。

謝謝大家的合作

0

這可能是因爲狀態欄,因爲它顯示在iPad的頂部,它存在於iPhone的白色地方。

+0

如果我刪除在第一屏中使用的攝像頭覆蓋視圖,並使用一個簡單的觀點那麼你如何從相機覆蓋添加此第一屏工程iPhone和iPad –

+0

罰款查看??發佈其代碼 – mayuur

+0

我添加了我用來添加覆蓋視圖到相機的代碼 –

相關問題