UITabelView GroupStyle 不同Section中自定义Cell For Row(xib模式)
来源:互联网 发布:淘宝店企业转个人 编辑:程序博客网 时间:2024/05/16 08:53
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
}else if (section == 1){
return 4;
}else if (section == 2){
return 1;
}
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.section == 0) {
cell = [self createSection1:indexPath];
}else if (indexPath.section == 1){
cell = [self createSection2:indexPath];
}else if (indexPath.section == 2){
cell = [self createSection3:indexPath];
}
return cell;
}
- (UITableViewCell*)createSection1:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ImageCell";
UITableViewCell *cell = (ImageCell *)[ContentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (indexPath.row == 0) {
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"ImageCell" owner:self options:nil];
for (id obj in nib) {
if ([obj isKindOfClass:[ImageCell class]]) {
cell = (ImageCell *)obj;
}
}
}
if (self.index == 1) {
[((ImageCell *)cell).TopImageView setImageWithURL:(NSURL *)touristImage];
}
}
return cell;
}
- (UITableViewCell*)createSection2:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
static NSString *cellIdentifier = @"Cell";
if (indexPath.row == 0) {
cell = (FactsCell *)[ContentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"FactsCell" owner:self options:nil];
for (id obj in nib) {
if ([obj isKindOfClass:[FactsCell class]]) {
cell = (FactsCell *)obj;
}
}
}
}else if (indexPath.row == 1){
cell = (MutiDetailCell *)[ContentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"MutiDetailCell" owner:self options:nil];
for (id obj in nib) {
if ([obj isKindOfClass:[MutiDetailCell class]]) {
cell = (MutiDetailCell *)obj;
}
}
}
}else {
cell = (PlusCell *)[ContentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"PlusCell" owner:self options:nil];
for (id obj in nib) {
if ([obj isKindOfClass:[PlusCell class]]) {
cell = (PlusCell *)obj;
}
}
}
}
if (indexPath.row == 0) {
((FactsCell *)cell).playLabel.text = @"2小时";
((FactsCell *)cell).opentimeLabel.text = @"上午 9:00 -下午 5:00";
}
else if (indexPath.row == 1) {
((MutiDetailCell *)cell).thumbView.image = IMAGE_WITH_NAME2(@"Tickets");
((MutiDetailCell *)cell).priceLabel.text = @"50元";
}
else if (indexPath.row == 2) {
((PlusCell *)cell).thumbView.image = IMAGE_WITH_NAME2(@"LandMarks");
((PlusCell *)cell).textLabel.text = @"达州市通川区上华路92号";
}
else if (indexPath.row == 3) {
((PlusCell *)cell).thumbView.image = IMAGE_WITH_NAME2(@"PhoneBig");
((PlusCell *)cell).textLabel.text = @"028-88888888";
}
return cell;
}
- (UITableViewCell*)createSection3:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
static NSString *cellIdentifier = @"SingelCell";
cell = (SingelCell *)[ContentTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"SingelCell" owner:self options:nil];
for (id obj in nib) {
if ([obj isKindOfClass:[SingelCell class]]) {
cell = (SingelCell *)obj;
}
}
}
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return 160;
}else if(indexPath.section == 1 && indexPath.row == 0){
return 87;
}else if(indexPath.section == 1 && indexPath.row == 1){
return 44;
}
else if (indexPath.section == 2){
return 100;
}
return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 1;
}
- UITabelView GroupStyle 不同Section中自定义Cell For Row(xib模式)
- cell for row index
- 使用xib自定义Cell
- 自定义cell 用xib
- xib 自定义cell
- 通过xib自定义cell
- iOS--xib自定义cell
- iOS ---xib自定义cell
- xib 自定义cell高度
- 通过xib自定义cell
- UITabelView中 cell 的复用机制
- UITabelView中cell点击展开功能设计
- IOS中xib+代码实现自定义cell中嵌套
- xib,story中自定义cell重用机制的一些疑问
- XIB自定义Cell重用问题
- 使用xib创建自定义Cell
- xib 自定义Cell(一)
- xib 自定义 Cell(二)
- X64位linux本地字符界面无法登录问题解决
- slf4j和Log4J使用过程中的if(logger.isDebugEnable())检查
- Qml 和外部js文件协同工作
- WPF学习第五集-X名称空间详解
- ubuntu 安装sqldeveloper
- UITabelView GroupStyle 不同Section中自定义Cell For Row(xib模式)
- Undefined symbols for architecture i386:和"_OBJC_CLASS_$_xx", referenced from:问题解决方法
- why use assertions in code
- js获取url传递参数(附其他参数办法)
- Android线程优先级
- WPF学习第六集-控件与布局
- 如何在Linux下自动启动Oracle服务
- 根据Hibernate实体对象,自动生成数据字典
- Xcode4.5出现时的OC新语法