1

ユーザーが無効なメールを入力したときに警告バブルを表示したい。バブルを正常に表示できますが、向きが変わるとバブルが存在している間、バブルが uitextfield と重なっています

ランドスケープとして開始を表示: ここに画像の説明を入力

向きが縦になります:

ここに画像の説明を入力

他の方法:

縦向きで開始を表示:

ここに画像の説明を入力

向きが横になる(泡が遠ざかる)

ここに画像の説明を入力

私のコード:

//image for warnings
        //get screen size
        CGRect screenRect = [[UIScreen mainScreen] bounds];
        float bubleOriginx;

        //detect device orientation
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
        if(orientation == UIInterfaceOrientationLandscapeLeft || orientation== UIInterfaceOrientationLandscapeRight)
        {
            bubleOriginx=screenRect.size.width*0.95;

        }else
        {
            bubleOriginx=screenRect.size.width*0.72;
        }


        UIImage *bubble = [[UIImage imageNamed:@"create event button.png"]
                       resizableImageWithCapInsets:UIEdgeInsetsMake(15, 21, 15, 21)];
        self.emailImage = [[UIImageView alloc] initWithImage:bubble];


        self.emailImage.frame = CGRectMake(bubleOriginx, self.email.frame.origin.y+28, 0, 0);
        UILabel  *xlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        xlabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
        xlabel.text = string;
        xlabel.numberOfLines = 0;

        CGSize labelSize = [xlabel.text sizeWithFont:xlabel.font
                                   constrainedToSize:xlabel.frame.size
                                       lineBreakMode:xlabel.lineBreakMode];
        xlabel.frame = CGRectMake(
                              xlabel.frame.origin.x, xlabel.frame.origin.y,
                              xlabel.frame.size.width, labelSize.height);


        [xlabel setBackgroundColor:[UIColor clearColor]];
        [self.emailImage addSubview:xlabel];
        self.emailImage.autoresizingMask =  UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;

        [self.view addSubview:self.emailImage];

        [UIView animateWithDuration:0.85
                         animations:^(void) {
                             self.emailImage.frame = CGRectMake(bubleOriginx, self.email.frame.origin.y+28, 220, -60);
                             xlabel.frame = CGRectMake(10, 0, 210, 60);
                         } completion:^(BOOL finished) {

                         }];

UIImageviewオーバーラップしないように安定させるにはどうすればよいですか?終点から常に+30ポイント離れているuitextfieldか、少なくとも重ならないとしましょう。

ありがとう、モード

4

1 に答える 1

0

これは autoResizingMask によるものです

    self.emailImage.autoresizingMask =  UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin;

キープUIViewAutoresizingFlexibleRightMargin; (ただし、期待どおりに動作しません)

ただし、向きの変更で origin.x を設定すると解決します。

CGRect tempFrame = self.emailImage.frame;
tempFrame.origin.x = textField.frame.origin.x+textField.frame.size.width+30;
self.emailImage.frame = tempFrame;

すべての向きに。textField が、画像に表示されている UITextField への参照であると仮定します。

于 2013-02-28T15:58:11.543 に答える