didSelectRowAtIndexPath中的活动指示符

时间:2011-05-20 06:52:18

标签: iphone

我试图在UIActivityindicator处设置didSelectRowAtIndexPath的动画,即当选择行时,它应该开始动画,直到没有加载其他视图。我正在尝试代码,但它没有做任何事,帮助!!!

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self. indicator stopAnimating];
        if(bdvController == nil)
        bdvController = [[BookDetailViewController alloc] initWithNibName:@"BookDetailView" bundle:[NSBundle mainBundle]];

        if(indexPath.section == 0)
    {       
        Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
        bdvController.aBook = aBook;
    }
    else if(indexPath.section == 1)
    {
        Book *aBook = [appDelegate.books objectAtIndex:indexPath.row+5*indexPath.section];
    bdvController.aBook = aBook;
    }
    [self.navigationController pushViewController:bdvController animated:YES];
 }


- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.indicator startAnimating];
    return indexPath;

}

2 个答案:

答案 0 :(得分:1)


创建一个 NSThread 作为调用选择器,如下所示:

[NSThread detachNewThreadSelector:@selector(threadStartAnimating:) 
                         toTarget:self 
                       withObject:nil];    
// Your code    
[spinner stopAnimating];    
[self.navigationcontroller pushviewcontroller:viewcontroller animated:YES]; 

threadStartAnimating:

-(void)threadStartAnimating:(id)data    
{    
    [spinner startAnimating];    
}  

答案 1 :(得分:0)

首先 [self.indicator.startAnimating];你想在这条线上做什么?您是在访问一个属性还是在调用方法。 而且我认为它将等待didSelectRow方法完成以显示indiacator。也许你可以尝试在

中显示指标
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

并在

中进行处理
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

由于您尚未粘贴与指标创建相关的代码。希望您已将表格视图单元格的选择样式设置为UITableViewCellSelectionStyleNone,并且还为指标视图设置了适当的框架。

相关问题