代码改变世界

一个界面使用两个或多个tableView

2014-09-28 17:51  蹲在墙角等红杏  阅读(281)  评论(0)    收藏  举报
#pragma - mark TableView Datasouce
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ([tableView isEqual:leftTableView]) {
        return 140;
    }
    else if ([tableView isEqual:rightTableView])
    {
        return 100;
    }
    return 0;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([tableView isEqual:leftTableView]) {
        static NSString *identifier = @"myCell";
        LeftCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell) {
            cell = [[[LeftCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]autorelease];
        }
        return cell;
    }
    else if ([tableView isEqual:rightTableView])
    {
        static NSString *identifier = @"mycell";
        RightCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (!cell) {
            cell = [[RightCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        return cell;
    }
    return nil;
}