0

在里面

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

if(indexPath.row==[self.peopleDataController countOfList]){

    static NSString *CellIdentifier = @"LastMoreCell"; 
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
    moreButton = [[UIButton alloc] initWithFrame:CGRectMake(140, 2, 42, 42)];

    [moreButton setImage:[UIImage imageNamed:@"more.png"] forState:UIControlStateNormal];

    [moreButton addTarget:self action:@selector(showMoreRows:) forControlEvents:UIControlEventTouchUpInside];

    [cell addSubview:moreButton];
    return cell;
}
 }


-(void) showMoreRows:(id)sender {

    MyAuraAppDelegate *delegate = (MyAuraAppDelegate *) [[UIApplication sharedApplication] delegate];
refreshlast = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

refreshSpinner.hidesWhenStopped = YES;

refreshlast.center = CGPointMake([[sender superview] superview].bounds.size.width / 2.0f, [[sender superview] superview].bounds.size.height / 2.0f);
[sender setHidden:YES];

[[sender superview].superview addSubview: refreshSpinner];
[refreshlast startAnimating];

    dispatch_queue_t dloadQueue = dispatch_queue_create("People refresh", NULL);
    dispatch_async(dloadQueue, ^{

        if ([[[GlobalVariable sharedInstance] peopleList] count] >0) {

            _peopleDataController = [_peopleDataController initPeopleListWithCoordinate:delegate.locationCoordinate2D auraId:delegate.myToken offset:0];


            NSLog(@"eerrrr %d",_peopleDataController.peopleList.count);

            //     _peopleDataController.peopleList=[[GlobalVariable sharedInstance] peopleList];
            for (int i=0; i< [_peopleDataController.peopleList count]; i++) {
                [[[GlobalVariable sharedInstance] peopleList ] addObject:[_peopleDataController.peopleList objectAtIndex:i]];                
            }

            _peopleDataController.peopleList =[[GlobalVariable sharedInstance] peopleList] ;
            NSLog(@"eerrr33r %d",_peopleDataController.peopleList.count); 
        }

        dispatch_async(dispatch_get_main_queue(), ^{  
            [self performSelector:@selector(addItem) withObject:nil afterDelay:2.0];
        });  
    });
    dispatch_release(dloadQueue);

}

但我的 UIActivityIndicatorView刷新最后没有显示,你能给我一些线索吗?

4

1 回答 1

0

我发现我的错误是:[sender superview].superview 是 tabview 而不是 tableviewcell 所以最后我修改了我的代码:

-(void) showMoreRows:(id)sender {

UIButton *button=(UIButton*)sender;
    MyAuraAppDelegate *delegate = (MyAuraAppDelegate *) [[UIApplication sharedApplication] delegate];
refreshlast = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

refreshSpinner.hidesWhenStopped = YES;

UITableViewCell *lastcell=(UITableViewCell*)[button superview];

refreshlast.center = CGPointMake(lastcell.frame.size.width / 2.0f, lastcell.frame.size.height / 2.0f);
NSLog(@"ddd %f",lastcell.frame.size.height);
[button setHidden:YES];

[lastcell addSubview:refreshlast];
[refreshlast startAnimating];

    dispatch_queue_t dloadQueue = dispatch_queue_create("People refresh", NULL);
    dispatch_async(dloadQueue, ^{

        if ([[[GlobalVariable sharedInstance] peopleList] count] >0) {

            _peopleDataController = [_peopleDataController initPeopleListWithCoordinate:delegate.locationCoordinate2D auraId:delegate.myToken offset:0];


            NSLog(@"eerrrr %d",_peopleDataController.peopleList.count);

            //     _peopleDataController.peopleList=[[GlobalVariable sharedInstance] peopleList];
            for (int i=0; i< [_peopleDataController.peopleList count]; i++) {
                [[[GlobalVariable sharedInstance] peopleList ] addObject:[_peopleDataController.peopleList objectAtIndex:i]];                
            }

            _peopleDataController.peopleList =[[GlobalVariable sharedInstance] peopleList] ;
            NSLog(@"eerrr33r %d",_peopleDataController.peopleList.count);




        }

        dispatch_async(dispatch_get_main_queue(), ^{  


            [self performSelector:@selector(addItem) withObject:nil afterDelay:2.0];
        }); 


    });
    dispatch_release(dloadQueue);

}

于 2012-07-05T08:31:30.567 回答