在我的應用程序中,我使用的是UIView
,其中包含UITableView
,Buttons
和Labels
。它使用Storyboard
創建。當用戶單擊一個導航欄按鈕UIView
將出現從頂部到一定高度的動畫,如果他們再次點擊它,它會用動畫隱藏UIView(從該高度到頂部)。 和UIActionView
相同。動畫UIView無法正常工作
如果UITableView
中沒有記錄,它可以正常工作。但如果它有任何記錄,在調用[self hideBasket]
時,UIView會從視圖底部出現到頂部(未隱藏)。
//隱藏籃碼
-(void)hideBasket{
/*Finished Hiding the Basket
[self.view sendSubviewToBack:_shoppingCartView];
[_shoppingCartView setHidden:YES];
_isShoppingCartSeen = NO;*/
CGRect basketFrame = _shoppingCartView.frame;
basketFrame.origin.y = -basketFrame.size.height;
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
_shoppingCartView.frame = basketFrame;
} completion:^(BOOL finished) {
// Finished Hiding the Basket
//[self.view sendSubviewToBack:_shoppingCartView];
// [_shoppingCartView setHidden:YES];
_isShoppingCartSeen = NO;
}];
//顯示籃碼
-(void)showBasket{
/*[self.view bringSubviewToFront:_shoppingCartView];
[_shoppingCartView setHidden:NO];
_isShoppingCartSeen = YES;*/
CGRect basketFrame = _shoppingCartView.frame;
basketFrame.origin.y = 0;
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
_shoppingCartView.frame = basketFrame;
} completion:^(BOOL finished) {
// Finished Showing the Basket
[self.view bringSubviewToFront:_shoppingCartView];
[_shoppingCartView setHidden:NO];
_isShoppingCartSeen = YES;
}];
}
我做錯的是什麼?
是否在故事板上選擇了AutoLayout? – 2014-10-29 15:04:29
@JimTierney是的,它是 – GoCrazy 2014-10-29 15:20:49