2011-04-22 115 views
0

我在表格視圖單元格中顯示一行文本。按下'編輯'按鈕並按下負號以顯示刪除按鈕。這將單元格中的文本推入兩行,導致單元格重疊。我的電池也有字幕。我有其他單元格中的文本,其中兩行,刪除時被截斷。我設置cell.textLabel.numberOfLines = 2這樣做,所以這不是一個問題。刪除表格視圖單元格時重疊

我怎樣才能讓一行文本只在一行顯示刪除按鈕時出現?按原樣將兩行文本保留在單元格中。

任何幫助將不勝感激!由於

回答

0

我設法找到解決辦法......它並不像我想

- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath { 

    Favorites *favorite = [fetchedResultsController objectAtIndexPath:indexPath]; 
    cell.textLabel.text = favorite.name; 
    NSLog(@"%d",[favorite.name length]); 
    NSLog(@"%@",favorite.name); 
    if ([favorite.name length] <= 34) { 
     cell.textLabel.numberOfLines = 1; 
     NSLog(@"no. of lines = 1"); 
    }else{ 
     cell.textLabel.numberOfLines = 2; 
     NSLog(@"no. of lines = 2"); 
} 
cell.detailTextLabel.text = favorite.subTopic;} 

configureCell方法被稱爲在我- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

基本上我檢查數量爲複雜字符串中的字符。我發現幻數是34個字符,以便一切都合適。

相關問題