为此前的项目做一个总结.
1) 逻辑问题 详情页面 根据接口的数据判断是否有相关的功能
// 判断button的个数
// 名字
self.buttoncount =1;
// 游戏视频
if ([self.stratearrcount] != 0) {
self.buttoncount++;
self.strateg =1;
}
if ([self.videoarrcount] != 0) {
self.buttoncount++;
self.video =1;
}
// 没有攻略和视频
if (self.buttoncount ==1) {
self.segmentbuttonview.backgroundColor = [UIColorclearColor];
self.heightone =YES;
}else {
self.heightone =YES;
// 有三个
if (self.buttoncount ==3) {
// 创建分段控制器
NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"游戏攻略",@"精彩视频",nil];
self.namesegmentcontroller = [[UISegmentedControlalloc] initWithItems:namearr];
self.namesegmentcontroller.frame =CGRectMake(10,0, 300,20);
self.namesegmentcontroller.tintColor = [UIColorcyanColor];
self.namesegmentcontroller.selectedSegmentIndex =0;
[self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];
[self.segmentbuttonviewaddSubview:self.namesegmentcontroller];
[_namesegmentcontrollerrelease];
self.video =1;
self.strateg =1;
}else if(self.buttoncount ==2 && self.strateg ==1) {
// 有游戏攻略
NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"游戏攻略",nil];
self.namesegmentcontroller = [[UISegmentedControlalloc] initWithItems:namearr];
self.namesegmentcontroller.frame =CGRectMake(10,0, 300,20);
self.namesegmentcontroller.tintColor = [UIColorcyanColor];
self.namesegmentcontroller.selectedSegmentIndex =0;
[self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];
[self.segmentbuttonviewaddSubview:self.namesegmentcontroller];
[_namesegmentcontrollerrelease];
}else if(self.buttoncount ==2 && self.video ==1){
// 精彩视频
NSMutableArray *namearr = [NSMutableArrayarrayWithObjects:@"游戏简介",@"精彩视频",nil];
self.namesegmentcontroller = [[UISegmentedControlalloc] initWithItems:namearr];
self.namesegmentcontroller.frame =CGRectMake(10,0, 300,20);
self.namesegmentcontroller.tintColor = [UIColorcyanColor];
self.namesegmentcontroller.selectedSegmentIndex =0;
[self.namesegmentcontrolleraddTarget:selfaction:@selector(buttonSelected:)forControlEvents:UIControlEventValueChanged];
[self.segmentbuttonviewaddSubview:self.namesegmentcontroller];
[_namesegmentcontrollerrelease];
}
}
2) 展开收起 高度控制 设定一个全局变量控制高度 随后的控件跟着变化
// 摘要内容
self.abructView = [[UIWebViewalloc] initWithFrame:CGRectMake(self.abructlabel.frame.origin.x,self.abructlabel.frame.origin.y +self.abructlabel.frame.size.height ,self.view.bounds.size.width,130 - 4)];
// 全局变量的高度
self.abractheight =130;
self.abructView.scrollView.scrollEnabled =NO;
[self.abructViewloadHTMLString: [[self.abractArrlastObject] detail_abstract ]baseURL:nil];
[self.whiteviewfouraddSubview:self.abructView];
[_abructViewrelease];
self.abtactbutton = [UIButtonbuttonWithType:UIButtonTypeCustom];
[self.abtactbuttonsetTitle:@"展开"forState:UIControlStateNormal];
self.abtactbutton.frame =CGRectMake(self.abructView.frame.origin.x + 280, self.abructView.frame.origin.y +self.abructView.frame.size.height,40, 20);
self.abtactbutton.backgroundColor = [WebColorblueViolet];
[self.abtactbuttonaddTarget:selfaction:@selector(zhanButtonClick:)forControlEvents:UIControlEventTouchUpInside];
[self.whiteviewfouraddSubview:self.abtactbutton];