iPhone:UIScrollview中的TableView,显示周围的空白滚动条
我在滚动视图中添加了一些表和其他VIE。在表格中滚动工作正常。但在父scrollview中,滚动时,会显示摇摆不定的垂直滚动条,有时甚至会出现在屏幕的中间。有时会显示在屏幕的左侧。并且不限于垂直滚动条区域。当我设置iPhone:UIScrollview中的TableView,显示周围的空白滚动条,iphone,uiscrollview,Iphone,Uiscrollview,我在滚动视图中添加了一些表和其他VIE。在表格中滚动工作正常。但在父scrollview中,滚动时,会显示摇摆不定的垂直滚动条,有时甚至会出现在屏幕的中间。有时会显示在屏幕的左侧。并且不限于垂直滚动条区域。当我设置showsVerticalScrollIndicator=NO时,它不会显示。但是你知道为什么滚动条在移动吗 DashboardView是UIScrollView的一个子类 dashboard=[[DashboardView alloc] initWithFrame:fullScree
showsVerticalScrollIndicator=NO
时,它不会显示。但是你知道为什么滚动条在移动吗
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];
}
dashboard=[[DashboardView alloc]initWithFrame:fullScreenRect];
dashboard.contentSize=CGSizeMake(320700);//一定要做!
dashboard.showsVerticalScrollIndicator=是;
dashboard.bounces=是;
self.view=仪表板;
@实现仪表板视图
-(id)initWithFrame:(CGRect)帧{
if(self=[super initWithFrame:frame]){
//初始化代码
}
回归自我;
}
-(void)drawRect:(CGRect)rect{
//绘图代码
}
-(无效)布局子视图{
NSArray*视图=self.subview;
[UIView beginAnimations:@“CollapseExpand”上下文:nil];
[UIView设置动画持续时间:0.5];
[UIView setAnimationBeginsFromCurrentState:是];
[UIView设置动画曲线:UIViewAnimationCurveEaseIn];
UIView*view=[views objectAtIndex:0];
CGRect=view.frame;
对于(inti=1;i<[视图计数];i++){
视图=[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委员会];
}
记住,滚动条也是滚动条的子视图。在对视图执行操作之前,将其从视图中排除。Yap。这解决了我的问题。滚动条似乎是一种UIImageView。如果有人需要它,这是我的新代码,运行良好
(void) layoutSubviews{
NSArray *views = self.subviews;
[UIView beginAnimations:@"CollapseExpand" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
// [self.view insertSubview:balanceView belowSubview:profileView];
UIView *view = [views objectAtIndex: 0];
CGRect rect = view.frame;
for (int i = 1; i < [views count]; i++ ) {
view = [views objectAtIndex:i];
if ([view isMemberOfClass: [UIView class] ]) {
//CFShow(view);
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];
(无效)布局子视图{
NSArray*视图=self.subview;
[UIView beginAnimations:@“CollapseExpand”上下文:nil];
[UIView设置动画持续时间:0.5];
[UIView setAnimationBeginsFromCurrentState:是];
[UIView设置动画曲线:UIViewAnimationCurveEaseIn];
//CGRect fullScreenRect=[[UIScreen mainScreen]applicationFrame];
//[self.view insertSubview:balanceView belowSubview:profileView];
UIView*view=[views objectAtIndex:0];
CGRect=view.frame;
对于(inti=1;i<[视图计数];i++){
视图=[views objectAtIndex:i];
if([view IsMemberOf类:[UIView类]]){
//CFShow(视图);
view.frame=CGRectMake(rect.origin.x,rect.origin.y+rect.size.height,view.frame.size.width,view.frame.size.height);
rect=view.frame;
}
}
[UIView委员会];
}