在我的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