仿qq列表

在有限的手机屏幕内,想展示更多的信息给用户,同时又不使用户感觉信息很多,此时将信息分类,以QQ列表形式进行展示是一种比较不错的选择,下面对这种方法进行简单介绍。

比较方便的方法就是使用系统提供的TableView列表,当点击某一行(标题)时,判断是否已经展开,然后根据展开与否对下面的cell进行增删,利用系统提供的动画效果,列表形式已经出现,很炫的;同时为了更好的展现,可以再cell.imageView中添加小三角,指示是否展开。OK,下面代码展示:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
    if (indexPath.row!=0) {
        return;
    }
    
    //动画
    NSIndexPath *index=[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
    UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:index];
    if (imageExpand ) {
        imageExpand=!imageExpand;
        [self rotateExpandBtnToCollapsed:cell];
    }
    else
    {
        imageExpand=!imageExpand;
        [self rotateExpandBtnToExpanded:cell];
    }
    
    NSMutableArray *indexPathArray=[[NSMutableArray alloc]init];
    for (int i=1; i<[[rootArray objectAtIndex:indexPath.section] count]; ++i) {
        [indexPathArray addObject:[NSIndexPath indexPathForRow:indexPath.row+i inSection:indexPath.section]];
    }
    if(indexPath.section == 0){
        if (Expanded) {
            Expanded=!Expanded;
            [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
        }
        else
        {
            Expanded=!Expanded;
            [tableView insertRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
        }
    }
    else if(indexPath.section == 1){
        if (Expanded_) {
            Expanded_=!Expanded_;
            [tableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
        }
        else
        {
            Expanded_=!Expanded_;
            [tableView insertRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationAutomatic];
        }
    }
}
其实判断是否展开,更好的方法可以用一个数组,然后对数组内的对象取boolValue进行判断,留给各位~\(≧▽≦)/~啦啦啦

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值