0

我有问题。。不明白为什么。。

我有一个只有一个 UIViewController 的故事板,它有一个 UITableView ( Outlet )。UITableView 有一个原型单元( Outlet )和他的自定义类。这个自定义类/这个原型单元有一个 UITableView ( Outlet ) 但是最后一个 tableView 没有出现,没有反应没有做任何事情......不明白为什么,IB中的链接是好的......

这是我的项目: https ://www.dropbox.com/sh/ouq6syndy489xgy/c5QbMsLDi7

这是控制没有反应的 UITableView 的代码:

#import "Cell.h"

@implementation Cell
@synthesize tableViewForCell;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView.layer setBorderColor:[UIColor grayColor].CGColor];
        [self.contentView.layer setBorderWidth:1.0f];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"hours"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"hours"];
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 30;
    //return  CGSizeMake(rect.size.width/X, rect.size.height/5);
}
4

1 回答 1

0

我刚刚下载了你的项目并检查了。我不能简单地回答你的问题。你做错了。您有一个带有原型单元格的表格视图,并且在此原型单元格中添加了另一个 tableview ,它不是单元格。

如果您需要自定义表格视图的单元格,请按照本教程进行操作,

http://www.appcoda.com/customize-table-view-cells-for-uitableview/

希望这可以帮助。

于 2012-11-15T11:22:15.647 回答