用UITableViewCell实现电子书平铺书架效果
原创文章,如需转载请注明:转载自:舵手程序 http://www.helmsmansoft.com/index.php/archives/70
现阶段网上讲解的实现这种效果的文章一般都是用UIVIew 去加载UIButton实现此功能,今天给大家说一下在UITableViewCell下怎样去实现这种效果
UITableViewCell默认是列表形态,默认状态下允许加载一张图片,如果想实现在UITableViewCell中显示多行图片,可以自定义UIView,把UIView加载到Cell上即可实现这种效果。这里主要说一下怎么去写Cell里的功能,其它功能不具体解释了。
具体见代码: 在theTableViewController.h中定义UIButton *buttonArray; 在theTableViewController.m文件内定义Cell中显示的图书本数
#define theNumberOfTatleTile 3 //每行显示3本
-
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section //每行3本,返回的行数 { if(%theNumberOfTatleTile == 0){ //listFileName 图书名字数组 return /theNumberOfTatleTile; }else{ return /theNumberOfTatleTile+1; } }
-
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *theKey = @"theKey"; UITableViewCell *cell = ; //注意此处 {
cell = initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:theKey] autorelease];
UILabel *customLabel = initWithFrame:CGRectMake(0, 0, 768, 1004)]; customLabel.backgroundColor = ; buttonArray = init]; NSUInteger row = ; for(int i = 0 ; i < /theNumberOfTatleTile;i++){ NSNumber *cellRow = initWithInt:theNumberOfTatleTile]; ; } for(int j = 0 ; j < %theNumberOfTatleTile; j++){ NSString *str = %theNumberOfTatleTile]; ; }
cell.imageView.image = NULL; cell.textLabel.text = NULL; cell.detailTextLabel.text = NULL; NSString *a = ; NSInteger b= ;
for(int m = 0 ; m < b; m++){
button = initWithFrame:CGRectMake(70+m%theNumberOfTatleTile*240, 20, 150, 200)]; UILabel *label= initWithFrame:CGRectMake(0, 170, 150, 30)]; forState:UIControlStateNormal]; label.backgroundColor = ; label.text = ; ;
button.backgroundColor = ; button.reversesTitleShadowWhenHighlighted = YES; ; ; // button.userInteractionEnabled = YES; // forState:UIControlEventTouchUpInside]; // forState:UIControlStateNormal]; // ; ;
} self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; UIImageView *imgView = initWithImage:]; cell.backgroundView = imgView; cell.selectionStyle = UITableViewCellEditingStyleNone; //选中CELL后效果 return cell;
} }
如果你喜欢本文,请去站点支持一下。分享给大家 舵手程序--http://www.helmsmansoft.com
转载本站文章请注明出处,转载自:舵手程序--http://www.helmsmansoft.com
本文链接地址: http://www.helmsmansoft.com/index.php/archives/70