我在滾動視圖中添加了一些表格和其他內容。滾動表格工作正常。但在父滾動視圖中,當滾動時,會顯示一個搖擺的垂直滾動條,有時甚至會到屏幕中間。有時顯示在屏幕的左側。而不限於垂直滾動條區域。當我設置showsVerticalScrollIndicator = NO
時,沒有顯示。但是你知道滾動條爲什麼會移動嗎?iPhone:TableView裏面的UIScrollview,顯示滾動條滾動條
DashboardView是UIScrollView
的子類。
dashboard=[[DashboardView alloc] initWithFrame:fullScreenRect];
dashboard.contentSize = CGSizeMake(320,700); // must do!
dashboard.showsVerticalScrollIndicator = YES;
dashboard.bounces = YES;
self.view = dashboard;
@implementation DashboardView
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (void)drawRect:(CGRect)rect {
// Drawing code
}
- (void) layoutSubviews{
NSArray *views = self.subviews;
[UIView beginAnimations:@"CollapseExpand" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
UIView *view = [views objectAtIndex: 0];
CGRect rect = view.frame;
for (int i = 1; i < [views count]; i++) {
view = [views objectAtIndex:i];
view.frame = CGRectMake(rect.origin.x, rect.origin.y + rect.size.height, view.frame.size.width, view.frame.size.height);
rect = view.frame;
}
[UIView commitAnimations];
}
那是一個很好的點。謝謝。我現在就來看看。 – karim 2010-04-27 12:57:06