-1
我有UIView,在它的頂部,我有一個UIImageView,在底部UICollectionView。我的觀點是,當用戶向上滑動手指時,UIImageView框架應該輕輕移出(消失),並且當用戶向下滑動時,它應該再次出現(使用移動動畫)。以編程方式移動UIImageView框架
實際上,它工作,直到我設置圖像到UIImageView。舊代碼(下面介紹)沒有它工作得很好:
-(void)handleSwipeDown:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"Swipe received.");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.myCollectionView.frame = CGRectMake(0, 152, 320, 480);
[UIView commitAnimations];
}
然後:
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {
NSLog(@"Swipe received.");
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.myCollectionView.frame=CGRectMake(0, 0, 320, 480);
[UIView commitAnimations];
}
後我設置圖像:
UIImage *firstImage = [UIImage imageNamed:@"ipd1.jpg"];
self.imageSlideshow.image = firstImage;
以上代碼停止工作。 UIImage框架保持在同一個地方。 我怎麼能讓它移動? 任何意見,將不勝感激,謝謝!
謝謝,但它不工作,圖像仍然在這裏。 – 2014-09-28 08:54:59
在代碼示例中,您正在移動myCollectionView的框架,但我認爲您還需要移動imageSlideshow以及? – believesInSanta 2014-09-28 08:57:09
那麼,其實在我的代碼imageView是不可見的,但在面對面,它的位置並沒有改變。我只是將collectionView的其餘部分「拉」起來(因爲在屏幕下方,它是隱形的)。 – 2014-09-28 09:03:54