2014-09-04 119 views
0

所以,我想將單元格添加到僅在沒有更多內容時才顯示的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

回答

0

通過創建不同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]; 
    ... 

}

相關問題