2013-06-11 4 views
0

내 응용 프로그램에서 두 번째보기 컨트롤러에서 테이블보기가 있습니다. 잠시 후 두 개의 버튼이있는 타이머를 사용하여 경고보기를 표시합니다. 예 아니오 (). 예를 클릭하면 경고보기가 닫히고 아니오를 클릭하면 표보기의 모든 항목이 삭제되고 다시로드됩니다.Tableview가 alertview에서 새로 고쳐지지 않았습니까?

문제

내가 첫 번째보기 컨트롤러에 가서 내가 같은 뷰 컨트롤러에서 오전 두 번째보기 controller.If로 돌아 가면 테이블보기를 새로 고침 할 수없는 오전, 그것은 완벽하게 다시로드합니다.

타이머 기능

start_Timer = [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(start_method) userInfo:nil repeats:NO]; 

알림이 시도

-(void)start_method 
    { 
      Timerfunction_alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have less than one minute before all items on your order list are released as it is about to exceed the 15-minutes hold time allocated to you to complete your order. Do you wish to continue ordering this item?" 
                  delegate:self 
                cancelButtonTitle:@"NO" 
                otherButtonTitles:@"YES", nil]; 
    [Timerfunction_alert show]; 
    } 



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
     if (alertView == Timerfunction_alert) 
     { 
     if (buttonIndex == 0) 
      { 
      //here to refresh the table view 
      [self.tableview reloaddata] 
     } 
     } 
} 
+0

난 당신이 우리에게 피투성이 세부 사항을 절약 할 수있는 새로 고침 코드를 생략 가정, 그러나 당신이이 작업이 있다면 나는 가정 reloadData' ('로 최종 호출이 존재해야하는 이유를 진단하기 어렵다 동일한보기 컨트롤러)가 더 많은 코드를 보지 않으면 작동하지 않습니다. – Rob

+0

어디서나 [tableView reloadData];를 호출하지 않았습니다. 이 메서드는 테이블 뷰 내에서 데이터를 새로 고치는 데 사용됩니다. – LAMBORGHINI

+0

@CodeBandits는 다시로드 날짜를 사용하지만 테이블보기를 새로 고칠 수 없습니다. – Yugesh

답변

0

을 보여

[self performSelector:@selector(start_method) withObject:nil afterDelay:30]; 
0

내 경험이 조각을 따라야합니다 하더군요

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
     if (alertView == paymentalert) 
     { 
     if (buttonIndex == 0) 
      { 
// reload table after main thread gets over, sothat app doesn't crash 
    [self performSelectorOnMainThread:@selector(ReloadTable) withObject:nil waitUntilDone:YES]; 

     } 
     } 
} 

//here to refresh the table view 
-(void)ReloadTable 
{ 
      [self.tableview reloaddata] 
} 
0
[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(start_method) userInfo:nil repeats:YES]; 

-(void)start_method 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have less than one minute before all items on your order list are released as it is about to exceed the 15-minutes hold time allocated to you to complete your order. Do you wish to continue ordering this item?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil]; 
    alert.tag=1; 
    [alert show]; 
    [alert release]; 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (alertView.tag==1) 
    { 
     if (buttonIndex == 1) 
     { 
      //here to refresh the table view 
      [self.tableview reloaddata] 
     } 
    } 
} 
관련 문제