0

테이블 뷰의 행을 클릭하면 다음 뷰의 테이블 laod가 사라질 때 dispear 및 활동 표시기를 추가하려고합니다. 코드 위구문 분석과 함께 활동 표시기를 추가하는 방법은 무엇입니까?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
if (indexPath.section == 1 && indexPath.row == 0) { 
    /*here add activity indiavtor*/ 

    iMapViewAppDelegate *appDelegate = (iMapViewAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    NSString *requestString = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/xml?origin=%@&destination=%@,OK&sensor=false",startField.text,endField.text]; 
    NSURL *url = [[NSURL alloc] initWithString:requestString]; 
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; 

    //Initialize the delegate. 
    xml1 *parser = [[xml1 alloc] init]; 

    //Set delegate 
    [xmlParser setDelegate:parser]; 


    //Start parsing the XML file. 
    BOOL success = [xmlParser parse]; 


    if(success){ 
     NSLog(@"No Errors"); 
     appDelegate.legAray=[parser.listofPoint copy]; 
     appDelegate.sAray=[parser.ListofSteps1 copy]; 
     arySteps=[[NSArray alloc]init]; 
     arySteps = [parser.ListofSteps1 arrayByAddingObjectsFromArray:parser.listofPoint]; 
     appDelegate.NoofRow=0; 
     appDelegate.NoofRow=[arySteps count]; 
     NSLog(@"%d",appDelegate.NoofRow); 
     NSLog(@"%@",arySteps); 
     sObject=[[Sleg alloc]init]; 
     sObject=[appDelegate.legAray objectAtIndex:0]; 

    } 
    else 
     NSLog(@"Error Error Error!!!"); 


     controller= [TableView alloc]; 
     controller.arayStep=[arySteps copy]; 
     [controller initWithNibName:@"TableView" bundle:nil]; 
     [self.navigationController pushViewController:controller animated:YES]; 
     [controller release]; 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

} 이 함수 호출은 다음 활동 표시 또는 MBProgressHUD를 추가하고 다음 도면에서 볼 때 row.In 해제를 선택하는 것이다. 어떻게 그럴 수 있죠?

답변

1
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
if (indexPath.section == 1 && indexPath.row == 0) 
{ 

    chkIndexPath = indexPath.row;  
    activity.hidden = FALSE; 
    [activity startAnimating]; 

    [self performSelector:@selector(myFunction) withObject:nil afterDelay:0.0]; 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 
- (void)myFunction 
{ 
    //your code. use chkIndexPath instead of indexPath.row 
} 

viewwillAppearactivity.hidden = TRUE;을 설정하십시오.

1

iRam11,
이 코드를 구현하고 문제가 있는지 물어보십시오.
NextView.h
선언

UIAlertView *av; 
UIActivityIndicatorView *actIndicator; 

NextView.m

in viewWillAppear call this callWebService Method 

-(void)callWebService { 
av = [[UIAlertView alloc] initWithTitle:@"Loading..." message:@"Please wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 
actIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease]; 
[actIndicator setFrame:CGRectMake(120, 70, 40, 40)]; 
[actIndicator setHidesWhenStopped:YES]; 
[av addSubview:actIndicator]; 
[actIndicator startAnimating]; 
[av show]; 
[av release]; 


//Do you web service call 
} 

-(void)parserDidEndDocument:(NSXMLParser *)parser { 
    // Do you tableview reload. 
    [av dismissWithClickedButtonIndex:0 animated:YES]; 
    actIndicator.hidden = YES; 
} 
관련 문제