2010-05-12 5 views
2

나는이 앱에 정말 의아해하고 있습니다. 제 신청서에 두 권의 UIActionSheets을 설정했습니다. UIActionSheets에서 취소 버튼을 사용하기 전까지는 완벽하게 작동합니다.UIActionSheet 취소 버튼으로 인해 내 앱이 계속 계속 작동합니다.

페이지에서 나가면 UIAactionSheet도 반환되어 내 응용 프로그램이 손상됩니다.

누구에게도 아이디어가 있습니까?

-(IBAction) phoneButtonClicked:(id)sender 
{ 
// open a dialog with just an OK button 
phoneActionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                delegate:self cancelButtonTitle:@"Cancel" 
                destructiveButtonTitle:nil 
                otherButtonTitles:[NSString stringWithFormat:@"Phone: %@",phone],nil]; 
phoneActionSheet.actionSheetStyle = UIActionSheetStyleDefault; 
[phoneActionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table) 
[phoneActionSheet release]; 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

if (actionSheet == phoneActionSheet) { 

    if(buttonIndex == 0){ 
      NSString *callPhone = [NSString stringWithFormat:@"tel:%@",phone]; 
      NSLog(@"Calling: %@", callPhone); 
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]]; 
    } 
} 

} 
+0

응용 프로그램이 충돌 할 때 콘솔에 아무 것도 기록되지 않습니까? 그렇다면 메시지를 게시하는 것이 도움이 될 것입니다. – jlehr

답변

1

나는 phoneButtonClicked에서 phoneActionSheet를 공개하지 않을 것을 제안합니다. 나쁜 포인터로 무언가를하려고 할 수도 있습니다. 또 다른 좋은 도움은 NSZombieEnabled을 사용하는 것입니다.

+0

콘솔에 아무 것도 기록되지 않았지만 릴리스 명령을 삭제해도 작동하지 않았습니다. – user337174

+0

시트가 릴리스되지 않고 누출 될 수 있습니다. 매번 phoneButtonClicked를 호출하면 더 이상 릴리스하지 않는 새 시트를 만듭니다. 그러나 시트가 작성된 후에는 시트를 닫은 후에이를 해제해야합니다. – JeremyP

+0

일반적으로 clickedButton 및/또는 취소 된 통화에서 작업 시트를 릴리스합니다. 이것은 최선은 아니지만 수명이 짧습니다. –

관련 문제