didSelectRowAtIndexPath中的活动指示符

问题描述 投票:1回答:2

我试图在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;

}
iphone
2个回答
0
投票

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

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

并进行处理

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

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


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];    
}  
© www.soinside.com 2019 - 2024. All rights reserved.