当前位置: 首页 > news >正文

站内推广的方法和工具实事热点新闻事件

站内推广的方法和工具,实事热点新闻事件,企业网站开发前台模块设计,wordpress图片轮播代码文章目录 前言一、实现效果二、折叠cell的实现原理三、实现折叠cell的高度变化四、实现选中点击的单元格总结 前言 在暑假的3GShare中用到了折叠cell控件#xff0c;特此总结博客记录 一、实现效果 二、折叠cell的实现原理 首先我们需要知道ScrollView的是TableView的父类特此总结博客记录 一、实现效果 二、折叠cell的实现原理 首先我们需要知道ScrollView的是TableView的父类我们可以通过代码来控制我们需要展示的cell的行数 也就是tableview的高度。 我们可以通过按钮来实现tableview的展开与关闭并且通过- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 方法来实现我们单元格的切换 三、实现折叠cell的高度变化 既然我们已经知道实现折叠cell的关键是通过按钮控制tableview的高度那么我们现在给出按钮点击函数 - (void)pressUp:(UIButton *)btn {if (btn.tag 1002) {[btn setImage:[UIImage imageNamed:shou.png] forState:UIControlStateNormal];_tableView.frame CGRectMake(270, 200, 95, 20);btn.tag--;} else {[btn setImage:[UIImage imageNamed:fang.png] forState:UIControlStateNormal];_tableView.frame CGRectMake(270, 200, 95, 80);btn.tag;} }如此一来便实现了我们点击按钮时我们展示的tableview高度会随按钮的点击而变化 四、实现选中点击的单元格 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {// 从_dataArray获取被选中的项目NSString *selectedItem _dataArray[indexPath.section];// 从_dataArray中移除被选中的项目[_dataArray removeObjectAtIndex:indexPath.section];// 将被选中的项目插入到_dataArray的开头[_dataArray insertObject:selectedItem atIndex:0];// 重新加载整个UITableView的数据[_tableView reloadData];// 调用pressUp:方法执行按钮状态的切换[self pressUp:_zhedie]; }当选择点击一个单元格时将所对应部分的数据从_dataArray中移动到数组的顶部。这在didSelectRowAtIndexPath方法中完成。然后重新加载UITableView并调用pressUp方法以确保正确的布局。 总结 如此一来我们便简单实现了我们的折叠cell 以下给出完整的简单折叠cell的实现代码 - (void)viewDidLoad {[super viewDidLoad];//折叠cell_tableView [[UITableView alloc] initWithFrame:CGRectMake(270, 200, 95, 80) style:UITableViewStylePlain];_tableView.delegate self;_tableView.dataSource self;_dataArray [NSMutableArray arrayWithObjects:cell1, cell2, cell3, cell4, nil];[self.view addSubview:_tableView];_zhedie [UIButton buttonWithType:UIButtonTypeSystem];_zhedie.frame CGRectMake(270 95, 200, 20, 20);_zhedie.backgroundColor [UIColor whiteColor];[_zhedie setImage:[UIImage imageNamed:shou.png] forState:UIControlStateNormal];[_zhedie addTarget:self action:selector(pressUp:)forControlEvents:UIControlEventTouchUpInside];_zhedie.tag 1001;[self.view addSubview:_zhedie];if (_zhedie.tag 1001) {_tableView.frame CGRectMake(270, 200, 95, 20);}//折叠cell}}//折叠cell - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return 1; }- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {return 4; }- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {return 20; }- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {NSString *selectedItem _dataArray[indexPath.section];[_dataArray removeObjectAtIndex:indexPath.section];[_dataArray insertObject:selectedItem atIndex:0];[_tableView reloadData];[self pressUp:_zhedie]; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {NSString *strID ID;//尝试获取可以复用的单元格//如果得不到返回为nilUITableViewCell *cell [_tableView dequeueReusableCellWithIdentifier:strID];if (cell nil) {cell [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strID];}//单元格文字赋值cell.textLabel.text [_dataArray objectAtIndex:indexPath.section];cell.textLabel.font [UIFont systemFontOfSize:12.0];cell.textLabel.textAlignment NSTextAlignmentLeft;return cell; }- (void)pressUp:(UIButton *)btn {if (btn.tag 1002) {[btn setImage:[UIImage imageNamed:shou.png] forState:UIControlStateNormal];_tableView.frame CGRectMake(270, 200, 95, 20);btn.tag--;} else {[btn setImage:[UIImage imageNamed:fang.png] forState:UIControlStateNormal];_tableView.frame CGRectMake(270, 200, 95, 80);btn.tag;} }折叠cell—demo
http://www.hkea.cn/news/14278404/

相关文章:

  • 顺德区网站设计建设企业门头沟青岛网站建设
  • 郑州做网站推广价格在win10下建设网站
  • 招商网站建设哪家好网站建设如何选择良好的服务器
  • 昆山移动网站建设深圳福田区福田社区
  • 祁阳seoseo 新旧网站 两个域名
  • 万网关网站三次建筑公司网站新闻
  • 上国外网站用什么dns在网站建设上的发言总结
  • 品牌网站建设公司哪好中国电信黄页网
  • 农特产品网站建设合同模板线上线下一体化营销
  • 创建站点的步骤网络推广渠道有哪些及策划思路
  • 用树莓派做网站服务器上海对外经贸大学
  • 国外域名拍卖网站做商城网站需要多少钱
  • 超级链接网站模板网站维护明细报价表
  • 如何做好网站关键词布局网站建设高手要学多久
  • 中国煤炭建设协会网站qc渝东建设工程造价信息网
  • 想给孩子找点题做 都有什么网站篇高端网站愿建设
  • 平台网站如何优化北京公司提供注册地址
  • 站酷网在线官网聊城市建设工程质量监督站网站
  • 佛山网站建设案例做粘土的网站
  • 百度官方网站首页网站建设的书籍有哪些
  • 音乐版权购买网站电商网站后台
  • 网站开发行业推广优质做网站费用
  • 互联网时代 网站建设网站短链接怎么做
  • 用凡科帮别人做网站个人网站服务器一年多少钱
  • 常用的cms建站系统国家工程建设标准化信息网站
  • 做网站最低级的软件网站结构合理
  • 电子商务网站建设子项目经销商管理系统
  • 网站制作 潍坊wordpress代码高亮插件
  • 网站建设需要服务器上海培训机构有哪些
  • 印度喜欢用什么框架做外贸网站同ip网站有什么影响