0
後,我已經創建了一個UIScrollView
編程,並且不滾動:的UIScrollView不滾動設置ContentSize
CGRect prevFrame;
BOOL isFirst = TRUE;
UIScrollView *view_scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
view_scroll.contentSize = CGSizeMake(650,224*[_cases count]+25*[_cases count]);
view_scroll.showsVerticalScrollIndicator = YES;
view_scroll.scrollEnabled = YES;
NSLog(@"%f",view_scroll.contentSize.height);
[self.view addSubview:view_scroll];
for(SLSCase* patientCase in _cases){
SLSCaseCard* caseCard = [[[NSBundle mainBundle] loadNibNamed:@"SLSCaseCard" owner:self options:nil] objectAtIndex:0];
if(isFirst){
caseCard.frame = CGRectMake(25,25, caseCard.frame.size.width, caseCard.frame.size.height);
isFirst = FALSE;
}
else{
caseCard.frame = CGRectMake(25, prevFrame.origin.y+caseCard.frame.size.height+25, caseCard.frame.size.width, caseCard.frame.size.height);
}
prevFrame = caseCard.frame;
[view_scroll addSubview:caseCard];
}
正如你可以看到我已經設置了contentSize和scrollEnabled。它仍然不滾動。
可能是您的內容大小小於您的滾動視圖框架。 –
您確定_cases中有物品嗎?你能否在屏幕上看到內容低於屏幕底部? – mikeyq6
嘗試首先將大小分配給CGSize變量並檢查值以確保大小正確 – mikeyq6