将单元格添加到UITableView的底部,该单元格仅在没有更多内容时出现

问题描述:

所以,我想将单元格添加到仅在没有更多内容时才显示的UITableView的底部。将单元格添加到UITableView的底部,该单元格仅在没有更多内容时出现

目标是,当列表中没有更多用户时,我想要一个显示有Twitter,Facebook等按钮的单元,以便用户可以邀请更多用户。任何提示?

所有最优秀的

+0

你是一个UITableView? – RotaJota 2014-09-04 19:46:28

+0

@RotaJota - 是:) – user3615707 2014-09-04 22:19:24

+0

@MateuszSzlosek - 以不同方式对细胞进行子类化。但没有运气 – user3615707 2014-09-04 22:19:43

通过创建不同NSTableViewCell的开始关闭 - 一个为你的常规数据,一个用于在结束你的‘社会化媒体’的细胞。

UITableViewDataSource,你可以为你的数据一个比行的总数越大

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [mDataSource count] + 1; 
} 

然后报告行数,在你cellForRowAtIndexPath方法,检查它是否是最后一行,并返回你的“社交媒体”单元。

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { 
    NSString *cellIdentifier = @"Cell"; 

    if (indexPath.row == [mDataSource count] + 1) { 
     cellIdentifier = @"SocialCell"; 
    } 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    ... 

}