2012-09-17 2 views
0

를 작동하지 않습니다RemoveFromSuperView (아래로)

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]; 
} 

물론 두 방법 모두 같은 클래스에 있습니다 ...

왜 화면에서보기가 제거되지 않습니까 ??

+0

당신의 [newAnnotationTitle resignFirstResponder]; 일하는거야? 근래에 그걸 확인해 봤어? – IronManGill

+0

CustomMsgBoxView를 두 번 설정하고 있습니다. 한 번은 이니셜 라이저로, 두 번째로 펜촉으로 된 물건으로. 그리고'vc = [ViewController sharedInstance] .self;'는 냄새를 풍기고 있습니다. – Abizern

+0

'removeFromSuperview'를 호출하기 직전에'aMustomMsgBoxView'가'hideMsgBox'에 가지고있는'NSLog' 값이 있습니까? 그것? – sergio

답변

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]; }]; 

} 

감사합니다 :)

관련 문제