多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > iOS tableViewCell點擊后顯示下拉菜單

iOS tableViewCell點擊后顯示下拉菜單

來源:程序員人生   發(fā)布時間:2014-10-10 08:00:01 閱讀次數(shù):4364次

//


1、具體的實現(xiàn)思路  就是 單機一個cell 的時候 在當(dāng)前cell下在添加一個自己定義好的Cell,話不多說  代碼如下,具體的過程從代碼中去體會吧 本代碼是從一個NT 的demo上整理出來的。


//  DDIUICtrl_Message.m

//  DDInsurance

//

//  Created by LeeYunHeNB on 14-9-26.

//  Copyright (c) 2014 XinMaHuTong. All rights reserved.

//


#import "DDIUICtrl_Message.h"

#import "DDIUICtrl_messageCell.h"

#import "DDUICtrl_menuCell.h"

@interface DDIUICtrl_Message ()


@property (weak, nonatomic) IBOutlet UITableView *my_tableView;

@property (nonatomic, strong) NSMutableArray *dataArray;

@property (assign)BOOL isOpen;

@end


@implementation DDIUICtrl_Message


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}


- (void)viewDidLoad

{

    [super viewDidLoad];

    [self setTitle:@"我的消息"];

    [self setLeftButtonText:@"" andBackground:[UIImage imageNamed:@"btn_back"]];

    NSDictionary *dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};

    NSArray * array = @[dic,dic,dic,dic,dic,dic];

    

    self.dataArray = [[NSMutableArray alloc]init];

    self.dataArray = [NSMutableArray arrayWithArray:array];

    

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    

    // Return the number of rows in the section.

    return self.dataArray.count;;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    

    // Return the number of sections.

    return 1;

}

// tableViewCell

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"])

    {

        

        static NSString *CellIdentifier = @"MainCell";

        

        DDIUICtrl_messageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        

        

        if (cell == nil) {

            cell = [[DDIUICtrl_messageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

            

            cell.selectionStyle = UITableViewCellSelectionStyleGray;

        }

//        cell.Headerphoto.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",indexPath.row%4+1]];

        

        return cell;

        

    }else if([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"AttachedCell"]){

        

        static NSString *CellIdentifier = @"AttachedCell";

        

        DDUICtrl_menuCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        

        

        if (cell == nil) {

            cell = [[DDUICtrl_menuCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

            

            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }

        

        return cell;

        

    }

    

    return nil;

}

// tableView點擊事件

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    

    NSIndexPath *path = nil;

    

    if ([[self.dataArray[indexPath.row] objectForKey:@"Cell"] isEqualToString:@"MainCell"]) {

        path = [NSIndexPath indexPathForItem:(indexPath.row+1) inSection:indexPath.section];

    }else{

        path = indexPath;

    }

    

    if ([[self.dataArray[indexPath.row] objectForKey:@"isAttached"] boolValue]) {

        // 關(guān)閉附加cell

        NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(NO)};

        self.dataArray[(path.row-1)] = dic;

        [self.dataArray removeObjectAtIndex:path.row];

        

        [self.my_tableView beginUpdates];

        [self.my_tableView deleteRowsAtIndexPaths:@[path]  withRowAnimation:UITableViewRowAnimationMiddle];

        [self.my_tableView endUpdates];

        

    }else{

        // 打開附加cell

        NSDictionary * dic = @{@"Cell": @"MainCell",@"isAttached":@(YES)};

        self.dataArray[(path.row-1)] = dic;

        NSDictionary * addDic = @{@"Cell": @"AttachedCell",@"isAttached":@(YES)};

        [self.dataArray insertObject:addDic atIndex:path.row];

        

        

        [self.my_tableView beginUpdates];

        [self.my_tableView insertRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationMiddle];

        [self.my_tableView endUpdates];

        

    }

    

    

}

@end




生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 亚洲高清二区 | 91日本在线观看亚洲精品 | 免费福利影院 | 狠狠操网站 | 国产a级午夜毛片 | 成人av在线播放 | 亚洲高清免费观看 | www视频在线观看 | 日韩亚洲一区中文字幕 | 老子午夜我不卡在线理伦 | 在线欧美日韩精品一区二区 | 精品久久成人免费第三区 | 欧美交性 | 直接在线观看的三级网址 | 黄色免费网址大全 | www日本高清 | 欧美另类视频一区二区三区 | 欧美午夜色大片在线观看免费 | 久久国产精品久久国产片 | japanese欧美| 亚洲精品老司机在线观看 | 波多野结衣在线观看一区 | 青青草原在线视频 | 国产精品99久久免费黑人 | 国产一级爱片在线播放 | 在线视频综合视频免费观看 | a级淫片 | 伊人久久久久久久久久 | 伊人网视频在线 | 亚洲最大黄色 | 欧美日韩亚洲区久久综合 | 国产高清在线精品二区一 | 欧美亚洲日本一区二区三区浪人 | 国内精品综合九九久久精品 | 亚洲人成在线播放网站 | 亚洲无线乱码高清在线观看一区 | 中国在线观看www视频 | 桃花福利视频在线观看 | 日本成本人在线观看免费视频 | 91精品国产高清久久久久 | 国语对白清晰好大好白在线 |