今日、私は奇妙な問題に直面しました。私はiPhoneとiPadで同じアプリケーションを持っていますが、普遍的なアプリケーションですが、iPhone用とiPad用の2つのメインのView Controllerを作っています。私はiPhoneのバージョンを最初に作った...その後、コードの一部をiPad版にコピーした。すべて私のロゴUIImageViewを除いて正常に動作するようです。私はロゴを画面からナビゲーションバーの中央にスライドさせる。アニメーションの前に、私はUIImageViewを画面外に設定しました。しかし、uiimageviewフレームのxとyに任意の値を入れても、それはまだ0です。これはiPhone上で同じコードですが、うまくいきます。UIImageViewがiPad上で正しく配置されない(常に0、0)
私の初期設定です。
UIImage *logoText = [UIImage imageNamed:@"logotext.png"];
[logoTextView setUserInteractionEnabled:YES];
logoTextView = [[UIImageView alloc] init];
// I already tried [[UIImageView alloc] initWithFrame:CGRectMake......];
logoTextView.frame = CGRectMake(389, -100, logoText.size.width, logoText.size.height);
logoTextView.image = logoText;
logoTextView.center = CGPointMake(389, -100);
logoTextView.alpha = 1;
[logoTextView addGestureRecognizer:resetGesture];
// [logoTextView setBackgroundColor:[UIColor whiteColor]];
[self.view insertSubview:logoTextView atIndex:10];
これは実際にスクリーンオフセンターと100pxににUIImageViewを配置すべきです。しかし、何も起こりません。それはまだ0です。私は知っているすべての方法を試してみましたが、何も実際に動作しません...
誰か知っている、何をすべきですか?それは本当に私を助けるだろう。 :)私は解決策を見つけた
EDIT
...私はなぜ知らないが、新しい方法で...奇妙な場合にのみ動作します。
- (void)logoShow {
UITapGestureRecognizer *resetGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resetValues)];
UIImage *logoText = [UIImage imageNamed:@"[email protected]"];
logoTextView = [[UIImageView alloc] initWithFrame:CGRectMake(389, -50, logoText.size.width/1.35, logoText.size.height/1.35)];
logoTextView.center = CGPointMake(389, -50);
logoTextView.image = logoText;
logoTextView.alpha = 1;
[logoTextView addGestureRecognizer:resetGesture];
[self.view insertSubview:logoTextView atIndex:15];
// LOGO TEXT ANIMATION
[UIView beginAnimations:@"Logo Text Animation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelay:4.5];
[UIView setAnimationDuration:0.5];
logoTextView.alpha = 1;
logoTextView.center = CGPointMake(389, 22);
[UIView commitAnimations];
[logoTextView setUserInteractionEnabled:YES];
}
を'init'ではなく、' UIView'とサブクラスのために指定された初期化子です。 – nielsbot
ありがとう、私はすでにそれを試みました。どちらもうまくいきません:/ –
私はそれが解決策ではないと言いましたが、それは私が信じている良い練習です。 – nielsbot