原型CellView中的TableView没有反应

时间:2012-11-15 10:43:13

标签: objective-c ios uitableview

我有一个问题......不明白为什么......

我有一个只有一个UIViewController的故事板,它有一个UITableView(Outlet)。 UITableView有一个Prototype Cell(Outlet)和他的Custom Class。 这个Custom类/这个Prototype Cell有一个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);
}

1 个答案:

答案 0 :(得分:0)

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

如果您需要自定义tableview的单元格,请按照本教程

进行操作

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

希望这有帮助。