0

私はヘッダーファイルでを宣言しUIViewましたが(以下のように):

IBOutlet UIView *aCustomMsgBoxView;

RemoveSuperViewは、一方のメソッドでは機能しますが、もう一方のメソッドでは機能しません。私がこの方法にそれを入れればそれは働きます:

-(IBAction)showMsgBox:(id)sender

{

vc = [ViewController sharedInstance].self;

aCustomMsgBoxView = [[UIView alloc] init];

NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"customMsgBox" owner:self options:nil];

aCustomMsgBoxView = [nibObjects objectAtIndex:0];

aCustomMsgBoxView.frame = CGRectMake(35, 80, 250, 146);

[vc.view addSubview:aCustomMsgBoxView];
}

しかし、私は上記の方法ではそれを必要としません、私はそれが機能しない以下の方法でそれを必要とします:

-(IBAction)hideMsgBox:(id)sender

{

    [newAnnotationTitle resignFirstResponder];

    [aCustomMsgBoxView removeFromSuperview];
}

もちろん、両方のメソッドは同じクラスにあります...

ビューが画面から削除されないのはなぜですか?

4

1 に答える 1

0

次のコードは、UIView(aCustomMsgBoxView)を削除するのに役立つ場合があります

  -(IBAction)hideMsgBox:(id)sender

{
    [newAnnotationTitle resignFirstResponder];

    [UIView animateWithDuration:0.25
     animations:^{ self.aCustomMsgBoxView.alpha = 0.0;}
     completion:^(BOOL finished){ [ self.aCustomMsgBoxView removeFromSuperview]; }];

}

ありがとう :)

于 2012-09-17T09:43:38.557 に答える