本文介紹了UIScrollView 不會滾動,即使在內容大小設置后的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我的 UIScrollView 是一個大約 4500 像素的水平視圖,用戶需要水平滾動才能查看內容.
我設置如下:
- (void)viewDidLoad{[超級視圖DidLoad];sview.frame = CGRectMake(0, 0, 568, 320);sview.contentSize = CGSizeMake(4500, 320);[sview setScrollEnabled:YES];}
然而滾動視圖什么也沒做.有什么明顯的我錯過了嗎?我已經嘗試過網絡上的每個教程.
解決方案
我遇到了類似的問題.我做了以下修改,scrollView 開始為我滾動:
- 選擇以檢查 UIScrollView 的水平反彈"屬性在西布.
- 將代碼后面的代碼移動到 viewDidAppear 而不是viewDidLoad:
<塊引用>
-(void) viewDidAppear:(BOOL)animated{[超級 viewDidAppear:動畫];sview.frame = CGRectMake(0, 0, 568, 320);sview.contentSize = CGSizeMake(4500, 320);[sview setScrollEnabled:YES];}
我認為這應該對你有所幫助.
My UIScrollView is a ~4500px horizontal view that the user needs to scroll horizontally through to view the content.
I have set it up as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
sview.frame = CGRectMake(0, 0, 568, 320);
sview.contentSize = CGSizeMake(4500, 320);
[sview setScrollEnabled:YES];
}
Yet the scroll view does nothing. Is there something obvious I missed? i've tried literally every tutorial on the web.
解決方案
I got similar issue. I did following modifications and the scrollView started scrolling for me:
- Select to check the 'Bounce Horizontally' property for UIScrollView in xib.
- Move the code following code to viewDidAppear instead of viewDidLoad:
-(void) viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; sview.frame = CGRectMake(0, 0, 568, 320); sview.contentSize = CGSizeMake(4500, 320); [sview setScrollEnabled:YES]; }
I think this should help you.
這篇關于UIScrollView 不會滾動,即使在內容大小設置后的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!