Ios5 为什么使用UIScrollView';在iOS 4.3中,s滚动会触发layoutSubViews方法,但在5.0&;在上面
我定制了UIView来创建自定义UI组件 视图的层次结构是这样的 ----自定义UIView ----------------UIScrollViewIos5 为什么使用UIScrollView';在iOS 4.3中,s滚动会触发layoutSubViews方法,但在5.0&;在上面,ios5,uiscrollview,ios4,layoutsubviews,Ios5,Uiscrollview,Ios4,Layoutsubviews,我定制了UIView来创建自定义UI组件 视图的层次结构是这样的 ----自定义UIView ----------------UIScrollView -(id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if(self){ //Allocation and Initialization of ScrollView //... [super addSubView:scrollView]; } retur
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
//Allocation and Initialization of ScrollView
//...
[super addSubView:scrollView];
}
return self;
}
- (void)layoutSubviews {
DLog(@"%@",[NSThread callStackSymbols]);
[super layoutSubviews];
[self reloadData];
}
//This method can be used to reload the entire control
-(void)reloadData{
//Reload the subviews of control
}
-----------------------------ScrollView中的子视图
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
//Allocation and Initialization of ScrollView
//...
[super addSubView:scrollView];
}
return self;
}
- (void)layoutSubviews {
DLog(@"%@",[NSThread callStackSymbols]);
[super layoutSubviews];
[self reloadData];
}
//This method can be used to reload the entire control
-(void)reloadData{
//Reload the subviews of control
}
每当滚动滚动视图时,都会在iOS版本4.3中调用layoutSubviews方法。但在4.3(5.0,6.0)以上的版本中,不会调用此事件处理程序
在我的用例中,我不希望调用LayoutSubView
如何确保在滚动时有一个不会触发layoutsubviews方法的滚动视图?我提出的解决方案如下:
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
//Allocation and Initialization of ScrollView
//...
[super addSubView:scrollView];
}
return self;
}
- (void)layoutSubviews {
DLog(@"%@",[NSThread callStackSymbols]);
[super layoutSubviews];
[self reloadData];
}
//This method can be used to reload the entire control
-(void)reloadData{
//Reload the subviews of control
}
--------------------------------------------ScrollView中的子视图
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
//Allocation and Initialization of ScrollView
//...
[super addSubView:scrollView];
}
return self;
}
- (void)layoutSubviews {
DLog(@"%@",[NSThread callStackSymbols]);
[super layoutSubviews];
[self reloadData];
}
//This method can be used to reload the entire control
-(void)reloadData{
//Reload the subviews of control
}
init方法现在更改为以下内容:
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
//Allocation and Initialization of Container View
[super addSubView:ScrollViewHolder];
//Allocation and Initialization of ScrollView
//...
[ScrollViewHolder addSubView:scrollView];
}
return self;
}