@implementation TRIPHotelXXXView{
// 类变量
}
- ( void )dealloc{
// 内存释放
SafeSuperDealloc( super );
}
- (id)initWithFrame:(CGRect)frame{
self = [ super initWithFrame:frame];
if (self) {
// 变量初始化
}
return self;
}
- ( void )layoutSubviews{
[ super layoutSubviews];
CGFloat y = 0.0 ;
// 子View的布局,y动态调整
// 更新自定义UI的高度
CGRect rect = self.frame;
rect.size.height = y;
self.frame = rect;
}
+ (instancetype)xxxView:(NSDictionary *)info width:(CGFloat)width;{
// 用view的数据及父view的宽度定义并初始化一个UI
TRIPHotelXXXView *view = [[TRIPHotelXXXView alloc] initWithFrame:CGRectMake( 0 , 0 , width, 0 )];
[view updateViewWithInfo:info];
return view;
}
- ( void )updateViewWithInfo:(NSDictionary *)info{
// view本身的数据填充
// 重新布局子View
[self layoutSubviews];
}
#pragma mark - Action
- ( void )onSomeActionHappened:(id)sender{
if (_delegate && [_delegate respondsToSelector: @selector (actionA)]) {
[_delegate actionA];
}
}
|