2011-12-22 56 views
0

在我的應用程序中是彈出窗口中的UITableView,它在新數據時重新加載。如果表中沒有分段,所有的作品完美與此代碼:分割的UITableView刷新

通知,其中發起重裝:

- (void)recieveNotification:(NSNotification*) notification { 
if ([[notification name] isEqualToString:@"NewDataArrived"]) { 
    [self viewWillAppear:YES]; 
} 

方法重載:

- (void)viewWillAppear:(BOOL)animated 
{ 
//Formation of the new content of table 

[self.tableView reloadData]; 
[super viewWillAppear:animated]; 
} 

但如果我排序的部分內容,一切順利混亂。查看不需要重新加載,只需將新數據添加到表格末尾即可。

標頭部分:

- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
if (section == 0) { 
    return @"Cities"; 
} else 
    if (section == 1) { 
     return @"Hotels"; 
    } else 
     if (section == 2) { 
      return @"Airports"; 
     } else 
return @"Landmarks"; 
} 

Here is screenshot http://dl.dropbox.com/u/8288064/img/chaos.png

我在這個麻煩上花了很多時間,並會很感激任何的建議。

回答

1

喜歡這個哥們!

.H

-(void)myOwnMethod:(id)sender; 

.M

-(void)myOwnMethod:(id)sender{ 

    [self.tableView reloadData]; 


} 
- (void)recieveNotification:(NSNotification*) notification { 
    if ([[notification name] isEqualToString:@"NewDataArrived"]) { 
      // [self viewWillAppear:YES]; 

     [self myOwnMethod]; 

    } 
} 
+0

不,它沒有工作,很遺憾。 – Akki 2011-12-22 09:26:47

+0

相反,它適用於非分區表格視圖。 – Akki 2011-12-22 09:32:34