0
在我看來位指示的viewDidLoad
功能,我有這樣的傢伙:爲什麼這個UIScrollView實驗失敗?
UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:self.view.frame];
scroller.contentSize = self.view.frame.size; // Tried w/ and w/o this
scroller.showsVerticalScrollIndicator = YES; // Tried w/ and w/o this
for (int x = 0; x < 10; x++) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, x * 100, 100, 100)];
label.text = [NSString stringWithFormat:@"%i label", x];
[scroller addSubview:label];
}
[self.view addSubview:scroller];
它顯示了前8個標籤OK,但滾動視圖不會...滾動。它只是被切斷。任何想法爲什麼?
同樣有用的是設置'contentSize'與我添加到它的對象的數量成比例。謝謝! – Wells