在我的didSelectRowAtIndexPath
方法中,当用户选择一个单元格以便在视图已经被呈现时消除该视图时,我呼叫[self dismissView];
。这显然不是非常优化的,并且它不覆盖presentView方法,而没有动画dismissView。有一个更好的方法吗?或者至少让它等待视图完成动画而不使用NSTimer。使用块排队动画
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
[self dismissView];
// Do xyz...
[self presentView:twitterLinksView];
然后..
- (void)presentView:(id)sender
{
twitterLinksView.frame = CGRectMake(0, (self.view.frame.size.height + viewHeight), 320, 300);
[UIView animateWithDuration:0.60f animations:^{
CGRect twitterLinkFrame = self.twitterLinksView.frame;
twitterLinkFrame.origin.y = (self.view.frame.size.height - viewHeight);
twitterLinksView.frame = twitterLinkFrame;
}];
}
- (void)dismissView
{
[UIView animateWithDuration:0.75f animations:^{
CGRect twitterLinkFrame = self.twitterLinksView.frame;
twitterLinkFrame.origin.y = (self.view.frame.size.height + viewHeight);
self.twitterLinksView.frame = twitterLinkFrame;
}];
}
动画结束时可能跟踪? http://stackoverflow.com/questions/10612389/what-is-the-best-way-to-wait-for-a-loop-of-uiview-animations-to-finish – 2013-03-27 20:58:53
不能说我发现这篇文章有帮助 – justMike 2013-03-27 21:45:51