1
Q
連續滾動圖像
A
回答
1
在這個例子中,我以總共5幅影像
- (void)viewDidLoad {
[super viewDidLoad];
// add the last image (image4) into the first position
[self addImageWithName:@"image4.jpg" atPosition:0];
// add all of the images to the scroll view
for (int i = 1; i < 5; i++) {
[self addImageWithName:[NSString stringWithFormat:@"image%i.jpg",i] atPosition:i];
}
// add the first image (image1) into the last position
[self addImageWithName:@"image1.jpg" atPosition:5];
scrollView.contentSize = CGSizeMake(320, 2496);
[scrollView scrollRectToVisible:CGRectMake(0,416,320,416) animated:NO];
}
- (void)addImageWithName:(NSString*)imageString atPosition:(int)position {
// add image to scroll view
UIImage *image = [UIImage imageNamed:imageString];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0,position*416,320, 416);
[scrollView addSubview:imageView];
[imageView release];
}
實現委託方法
- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender {
NSLog(@"%f",scrollView.contentOffset.y);
// The key is repositioning without animation
if (scrollView.contentOffset.y == 0) {
// user is scrolling to the left from image 1 to image 4
// reposition offset to show image 4 that is on the right in the scroll view
[scrollView scrollRectToVisible:CGRectMake(0,1664,320,416) animated:NO];
}
else if (scrollView.contentOffset.y == 2080) {
// user is scrolling to the right from image 4 to image 1
// reposition offset to show image 1 that is on the left in the scroll view
[scrollView scrollRectToVisible:CGRectMake(0,416,320,416) animated:NO];
}
}
1
我給出兩個參考鏈接,自動滾動,滾動圖,其中還可以虎視眈眈的源代碼,並落實到你的項目這是驚人的funcationality
1)Automatically scroll the scroll view
2)As par your requirement created post of like wise gallery.
本帖子對您有所幫助。
快樂codeing 感謝和問候,
@Samuel
相關問題
- 1. 使用滾動標籤連續滾動滾動圖像
- 2. FullPage.JS連續滾動
- 3. 僞連續滾動
- 4. Windows Phone 8中圖像的自動連續滾動
- 5. 連續自動滾動ListView
- 6. 連續滾動圖片橫幅Jquery
- 7. 在jQuery中連續滾動包含圖像的水平滾動條?
- 8. 尋找一個jQuery連續圖像滾動條
- 9. 如何使用jquery垂直連續滾動圖像
- 10. 繼續爲圖像滾動效果?
- 11. 在wpf中的圖像控件中從上到下連續滾動圖像c#
- 12. 連續/無限滾動
- 13. 停止連續滾動smoothdivScroll
- 14. 連續滾動的問題
- 15. 水平連續滾動EditText
- 16. 離子連續滾動
- 17. jQuery垂直連續滾動
- 18. CarouselLite不連續滾動
- 19. 自動連續顯示圖像
- 20. UITableView斷斷續續滾動沒有圖像或內容提取
- 21. 連續滾動div菜單動畫jumpy
- 22. 如何讓背景圖像連續水平滾動而不中斷動畫?
- 23. Gulp連續生成圖像
- 24. HTML佈局:連續圖像
- 25. 將圖像連續對齊
- 26. 旋轉圖像連續
- 27. 連續旋轉圖像
- 28. 滾動圖像
- 29. 滾動視圖與圖像不滾動
- 30. 連續的HTML頁面滾動
我想你問爲此, http://stackoverflow.com/questions/3763978/360-panorama-librarys-for-ios。 – Vignesh 2012-02-16 07:06:23