我目前正在研究將幾個UIImageView
添加到單個UIScrollView
的方法。 UIScrollView
將是UIImageViews
中任意一個的1.5倍。我想創建一個滾動效果來瀏覽iPad應用程序中的一些小圖像。有誰知道如何做到這一點?將UIImageView添加到UIScrollView
4
A
回答
11
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(/*FRAME*/)]; // this makes the scroll view - set the frame as the size you want to SHOW on the screen
[scrollView setContentSize:CGSizeMake(/*SIZE OF THE CONTENT*/)]; // if you set it to larger than the frame the overflow will be hidden and the view will scroll
/* you can do this bit as many times as you want... make sure you set each image at a different origin */
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"/*IMAGE*/"]]; // this makes the image view
[imageView setFrame:CGRectMake(/*SET AS 2/3 THE SIZE OF scrollView AND EACH IMAGE NEXT TO THE LAST*/)]; // this makes the image view display where you want it and at the right size
[scrollView addSubview:imageView]; // this adds the image to the scrollview
/* end adding image */
[self.view addSubview:scrollView];
1
相關問題
- 1. 將UIImageView添加到UIScrollView
- 2. 對象泄漏:添加UIImageView並將其移除到UIScrollView
- 3. 將UUD添加到UIImageView
- 4. 將註釋添加到UIImageView
- 5. 將UILabel添加到UIImageView
- 6. 將UIRefreshControl添加到UIScrollView
- 7. 將Stackview添加到UIScrollView
- 8. 將按鈕添加到UIScrollview
- 9. 將tapRecognizer添加到UIScrollView
- 10. 添加UIImageView到UIView
- 11. 添加IBActions到UIScrollView
- 12. iOS:在ASIHTTP完成提取圖像數據之前將UIImageView添加到UIScrollView中
- 13. 將UIImageView添加到後臺線程中的UIScrollView,不會顯示直到全部添加
- 14. 如何將UIPanGestureRecognizer添加到UIImageView中
- 15. UIScrollView在將圖像加載到UIImageView時掛起
- 16. 將viewController視圖添加到UIScrollView
- 17. 將UIView添加到UIScrollView的頂部
- 18. 將靜態UIButton添加到UIScrollview中
- 19. 如何將UIControls添加到UIScrollView contentView?
- 20. 將UIViewController添加到UIScrollView swift 3
- 21. 如何將UIScrollView添加到UIAlertView
- 22. 如何將UIScrollView添加到Interface Builder?
- 23. UIScrollView或UIImageView?
- 24. UIImageView在UIScrollView?
- 25. 添加文本到UIImageView
- 26. UIImageView沒有添加到UIView
- 27. 無法將UIScrollView添加到另一個UIscrollView
- 28. 添加UITapGestureRecognizer到的UIScrollView
- 29. 添加筆尖到UIScrollView中
- 30. 添加縮放到UIScrollView
好吧,你有隊友!會試試看! – TheLearner 2010-09-23 10:42:48
很好的解釋感謝隊友。無論如何強迫滾動條始終可見嗎? – TheLearner 2010-09-23 11:00:37
或使其成爲動畫或其他方式,以便用戶知道他們可以滾動 – TheLearner 2010-09-23 11:08:38