当用户点击一个单元格时,我正在为表视图设置动画。虽然我第一次点击单元格时会调用我的DidSeclectRowAtIndexPath,但动画不会发生。在第二次点击时,动画块被触发。 可能导致此问题的原因是什么?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.ChosenSubCategory=[self.SubCategoryListArray objectAtIndex:indexPath.row];
[self getUserSpecificLevelDetails];
// [self ShowLevelPickerView];
[UIView animateWithDuration:1.0 animations:^{
[self.ChooseLevelView setCenter:CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2)];
[player prepareToPlay];
[player play];
}];
}
答案 0 :(得分:0)
可能是因为线程问题。
请尝试以下解决方案。希望它有效。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
*)indexPath
{
self.ChosenSubCategory=[self.SubCategoryListArray objectAtIndex:indexPath.row];
[self getUserSpecificLevelDetails];
// [self ShowLevelPickerView];
[self performSelector:@selector(performOperation) withObject:nil afterDelay:0];
}
- (void)performOperation
{
[UIView animateWithDuration:1.0 animations:^{
[self.ChooseLevelView setCenter:CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2)];
[player prepareToPlay];
[player play];
}];`
}