纯代码实现cell嵌套cell
来源:互联网 发布:手机淘宝联盟自动发单 编辑:程序博客网 时间:2024/05/24 15:42
#import "ViewController.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
UITableView * rootTable;
UITableView * tableView1;
NSMutableArray * ChildArr;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
[self initView];
ChildArr = [[NSMutableArrayalloc]initWithObjects:@"苹果",@"栗子",@"香蕉",@"菠萝",nil];
self.navigationItem.title =@"TwoTableView";
}
-(void)initView
{
rootTable = [[UITableViewalloc]initWithFrame:CGRectMake(0,64,320,480-64)style:UITableViewStyleGrouped];
rootTable.delegate =self;
rootTable.dataSource =self;
rootTable.separatorColor=[UIColorgreenColor];
[self.view addSubview:rootTable];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == rootTable)
{
return 300;
}else
{
return 44;
}
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == rootTable)
{
return 4;
}else
{
return [ChildArrcount];
}
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [[UITableViewCellalloc]init];
if (tableView == rootTable)
{
tableView1 = [[UITableViewalloc]initWithFrame:CGRectMake(150,40, 150, [ChildArrcount]*44)];
tableView1.delegate =self;
tableView1.dataSource =self;
tableView1.scrollEnabled =NO;
[cell.contentView addSubview:tableView1];
UILabel * label=[[UILabelalloc]initWithFrame:CGRectMake(10,5, 300, 30)];
label.text=@"和《星你》一起玩星星游戏";
[cell.contentView addSubview:label];
UIImageView * imageV=[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"81.jpg"]];
imageV.frame=CGRectMake(10,40, 130, 140);
[cell.contentView addSubview:imageV];
UIImageView * imageV1=[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"2.jpg"]];
imageV1.frame=CGRectMake(10,200, 90, 90);
[cell.contentView addSubview:imageV1];
UILabel * label1=[[UILabelalloc]initWithFrame:CGRectMake(110,210, 200, 100)];
label1.numberOfLines=0;
label1.font=[UIFontsystemFontOfSize:14];
label1.text=@"一二三四一二三四和《星你》一起玩星星游戏和《星你》一起玩星星游戏和《星你》一起玩星星游戏和《星你》一起玩星星游戏";
[cell.contentView addSubview:label1];
return cell;
}else
{
UIImageView * imageV=[[UIImageViewalloc]initWithFrame:CGRectMake(0,0, 40, 40)];
imageV.image=[UIImageimageNamed:@"81.jpg"];
[cell.contentView addSubview:imageV];
UILabel * label=[[UILabelalloc]initWithFrame:CGRectMake(50,0, 110, 44)];
label.text=@"fdfdfdfdf guo wen tao shi shei";
label.numberOfLines=0;
label.font=[UIFontsystemFontOfSize:14];
[cell.contentView addSubview:label];
return cell;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == rootTable)
{
NSLog(@"roottableView");
}else
{
NSLog(@"苹果");
}
}
@end
- 纯代码实现cell嵌套cell
- 纯代码实现自定义UITableView的cell
- 使用纯代码自定义cell
- cell中嵌套cell
- 纯代码自定义cell,并且实现动态调整
- IOS中xib+代码实现自定义cell中嵌套
- 纯代码自定义cell(cell高度不一致)
- 自定义等高的cell(纯代码)
- 纯代码自定义cell的过程
- 0917 纯代码、SB、XIB自定义Cell
- 纯代码和Storyboard搭建Cell
- 纯代码计算不等高cell
- 猫猫学IOS(十七)UI之纯代码自定义Cell实现新浪微博UI
- AJ学IOS(17)UI之纯代码自定义Cell实现新浪微博UI
- iOS - 纯代码实现几种不同类型高度固定的Cell
- UITableView cell嵌套textView
- iOS UITableView(一)-纯代码创建UITableView,Cell点击事件,Cell左滑删除
- 自定义不等高的cell(纯代码frame)
- 解决android上java.net.UnknownHostException: Unable to resolve host "xxxx"
- JAVA虚拟机之三:CMS垃圾收集器
- 欢迎使用CSDN-markdown编辑器
- 2015年大二上-数据结构-数组与广义表(2)-2.压缩存储的对称矩阵的运算
- Bitmap的基础综合
- 纯代码实现cell嵌套cell
- Sublime Text 无法使用Package Control或插件安装失败的解决方法
- Redis 存储JavaBean对象(默认是不支持的,只能让该javabean继承序列化接口实现)
- CentOS 7.1安装GNOME,开启VNC Server
- Git 远程服务器搭建
- 如何计算任意两分数
- IOS开发之NSDictionary里setValue:forKey与setObject:forKey、objectForKey与valueForKey的差异
- CenOS6.x 下Twisted安装
- android 属性动画的一些经验