2009-08-31 12 views

उत्तर

3

उपयोग [tableView reloadData] ui तालिका दृश्य पर विधि

+0

बस सावधान रहना होगा यह कर संपादन मोड में है। – Amagrammer

0

ठीक .. लेकिन .. हम इस के लिए समाधान .. जरूरत है हम क्रम में कोशिकाओं जोड़ते हैं, तो मैं में एक ही कोशिकाओं के साथ उत्पादन प्राप्त हुआ है UITableView के पहले और अंतिम कोशिकाओं ..

आप स्पष्ट सेल से पहले

उदाहरण किसी भी subviews जोड़ सकते हैं:

[mytableview.contentView clearsContextBeforeDrawing]; 
24

साफ अपने डेटा आर कॉल करने से पहले eloadData, और अब उपयोगकर्ता को तालिका को साफ़ किया जाएगा और ताजा डेटा के साथ फिर से पॉप्युलेट किया जाएगा।

myArray = nil; 
[myTableView reloadData]; 
0

आप पुन: उपयोग किए गए सेल के मूल्य को देख सकते हैं और यदि यह समान नहीं है - तो इसे फिर से बनाएं।

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
MyLog(@"Start Table: cellForRowAtIndexPath: %d", indexPath.row); 

NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row]; 
UILabel *lblNew; 
lblNew = [UILabel new]; 
UILabel *lblCell; 
lblCell = [UILabel new]; 

MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

if (cell == nil) 
{ 
    cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 
    [cell.contentView addSubview:[lblNameArray objectAtIndex:indexPath.row]];  
} 
else 
{ 
    lblNew = [lblNameArray objectAtIndex:indexPath.row]; 
    for (id label in [cell.contentView subviews]) 
    { 
     if ([label isKindOfClass:[UILabel class]]) 
     { 
      lblCell = label; 
     } 
    } 
    if (![lblNew.text isEqualToString:lblCell.text]) 
    { 
     cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 
     [cell.contentView addSubview:[lblNameArray objectAtIndex:indexPath.row]]; 
    } 
} 
return cell; 
2

यह मेरा काम था जो काम करता था। सेट सेल = शून्य;

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
cell = nil; 
-1

स्क्रॉलिंग के बाद चयन पर मुझे डबल प्रविष्टियां थीं। अब प्रदर्शन अपेक्षित के रूप में साफ है! वैकल्पिक हल

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
cell = nil; 

और भी प्रयोग किया जाता है (Btw:। ClearsContextBeforeDrawing के रूप में यह स्वसंपूर्ण

[cell.contentView clearsContextBeforeDrawing]; 
सिम्युलेटर में

काम नहीं किया मैं सेल चयन पर अधिक सटीक प्रतिक्रिया की छाप है धन्यवाद

!
1

वैसे, clearsContextBeforeDrawing एक संपत्ति है, और

[cell.contentView clearsContextBeforeDrawing]; 

इसके मूल्य को वापस करने के अलावा कुछ भी नहीं करता है।

0

स्विफ्ट: सुनिश्चित नहीं यह सबसे अच्छा तरीका है या नहीं है, लेकिन मैं स्पष्ट करने के लिए इस कोड का उपयोग कर रहा हूँ और डाटा roload:

fileprivate func clearTable() { 
    self.tableviewData.removeAll(keepingCapacity: false) 
    self.tableView.reloadData() 
}