0

iPhoneアプリをiPadに変換しようとしていますが、ルートView Controllerまではすべて問題ありません。それはコードに組み込まれており、何をしてもサイズを変更したり中央に配置したりすることはできません。ホームページのペン先がありません。マスクの自動サイズ変更は何もしません.iPadペン先を追加しても、最善の努力にもかかわらず何もしませんが、iPhone画面を左上に表示し続け、if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 空白の黒いiPad画面をロードします. 私は今何をすべきか本当にわかりません。画面要素をinitWithFrame:[[UIScreen mainScreen] bounds]];アートワークに設定すると、伸びすぎて歪みます。

// 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ビューを作成するにはどうすればよいですか? iPhoneの画面を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)];

編集ここで何が欠けているのか本当にわかりません。これを丸一日続けています。コードに組み込まれたiPhone画面にxibを遡及的に追加することはできないようです。いつも左上にくっついているよりも。それもうまくいきません。

4

1 に答える 1

0

わかりました

必要に応じて調整できるように、最終的に xib を追加するようにしました。rootview コントローラーでこのコード行を見逃していたため、以前は xib を初期化できませんでした。

- (id)init
{

[[NSBundle mainBundle] loadNibNamed:@"ICHomeController" owner:self options:nil];
于 2012-10-04T18:17:45.923 に答える