2012-10-04 5 views
0

내 루트보기 컨트롤러까지 모두 내 아이폰 앱을 ipad로 변환하려고합니다. 그 코드에 내장되어 있고 상관없이 내가 그것을 기울이지/센터 그것을 조정할 수 없습니다. 내 홈페이지에 펜촉이 없습니다. 자동 조절 마스크는 아무 것도하지 않고 iPad 펜촉을 추가하면 최선의 노력에도 불구하고 아무 것도하지 않지만 왼쪽 상단에 iPhone 화면을 계속 표시하고 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)을 사용하면 빈 검은 색 iPad 화면이로드됩니다. 나는 지금 무엇을 해야할지 정말로 모른다. 화면 요소를 initWithFrame:[[UIScreen mainScreen] bounds]];으로 설정하면 아트 워크가 펴질 때 왜곡됩니다.루트보기 컨트롤러가 코드로 작성되었습니다. iPad 용으로 크기를 조정하지 않습니다.

// Create the main view 
UIView *mainView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
mainView.backgroundColor = [UIColor blackColor]; 



if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 

UIImageView *textureBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768.0f, 1024.0f)]; 
textureBg.image = [UIImage imageNamed:@"BgTexture"]; 
[textureBg addSubview:textureBg]; 
} 
else { 

// Add textured background 
UIImageView *textureBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320.0f, 1024.0f)]; 
textureBg.image = [UIImage imageNamed:@"BgTexture"]; 
[textureBg addSubview:textureBg]; 

} 


if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {  

UIImageView *clipBg = [[UIImageView alloc] initWithFrame:CGRectMake(7.0f, 6.0f, 605.0f, 865.0f)]; 
clipBg.image = [UIImage imageNamed:@"BgHomeNew2"]; 
clipBg.userInteractionEnabled = YES; 

} 
else { 
// Add clipboard background 
UIImageView *clipBg = [[UIImageView alloc] initWithFrame:CGRectMake(7.0f, 6.0f, 305.0f, 465.0f)]; 
clipBg.image = [UIImage imageNamed:@"BgHomeNew2"]; 
clipBg.userInteractionEnabled = YES; 
//[clipBg setAutoresizingMask:(UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin)]; 


    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 

// Add about button to clipbg 
UIButton *aboutButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
aboutButton.frame = CGRectMake(240.0f, 90.0f, 31.0f, 33.0f); 

[aboutButton setImage:[UIImage imageNamed:@"LabelButton"] forState:UIControlStateNormal]; 
[aboutButton addTarget:self action:@selector(aboutButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
[aboutButton addSubview:aboutButton]; 

} 
else { 
// Add about button to clipbg 
UIButton *aboutButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
aboutButton.frame = CGRectMake(240.0f, 90.0f, 31.0f, 33.0f); 

[aboutButton setImage:[UIImage imageNamed:@"LabelButton"] forState:UIControlStateNormal]; 
[aboutButton addTarget:self action:@selector(aboutButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; 
[aboutButton addSubview:aboutButton]; 
} 

루트보기 컨트롤러가 코드로 작성된 범용 앱의 경우 ipad보기를 어떻게 만들 수 있습니까? 심지어 ipad 화면의 중앙에 아이폰 화면을 중심에 둔다는 아이디어에 대해서도 열지 만, 자동 응답은 상단 왼쪽에 붙어있을뿐입니다. 이것은 IB에서 2 분이 될 것입니다!

왜 다음 코드는 이미지를 iPad 화면의 중심으로 옮기는 지 요약하면됩니까?

UIImageView *clipBg = [[UIImageView alloc] initWithFrame:CGRectMake(7.0f, 6.0f, 305.0f, 465.0f)]; 
clipBg.image = [UIImage imageNamed:@"BgHomeNew2"]; 
clipBg.userInteractionEnabled = YES; 
[clipBg setAutoresizingMask:(UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin)]; 

편집 정말이 지금은 하루에하고, 캔트 코드에 내장 된 아이폰 화면으로 후 향적 XIB를 추가하는 것 메신저 여기에없는 것을 잘 모릅니다, 그래서 중간에 객체를 중심으로 정착됩니다 항상 왼쪽 상단에 붙어 있기보다는 ipad가 사용될 때 화면의 그 dosent 중 하나를 작동합니다.

+0

"iPhone/iPad"로 설정된 "대상 장치 제품군"이 있습니까? 또한 창 크기를 적절하게 만드십니까? – ader

+0

예, 내 모든 다른보기는 펜촉이 있고, ~ ipad 펜촉은 이것들 모두 잘 작동합니다.이 한 화면은 코드에 내장되어 있습니다. – JSA986

+0

크기를 조정하려는 것은'mainView '처럼 들립니다. 보기가 창에 어떻게 추가됩니까? '[textureBg addSubview : textureBg];와'[aboutButton addSubview : aboutButton];이 어떻게 될 것으로 기대합니까? – Jonah

답변

0

좋아 그것을 분류

필자 마지막으로 내 rootview의 콘트롤에 코드 줄을 놓쳤다 때문에 그래서 내가 전에 xibs을 초기화 할 수 없습니다, 필요에 따라 조정할 수 있습니다 지금 xibs을 추가 마 제드

- (id)init 
{ 

[[NSBundle mainBundle] loadNibNamed:@"ICHomeController" owner:self options:nil]; 
관련 문제