2012-05-01 99 views

回答

0

你必須使用NSSortDescriptor: -

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    NSSortDescriptor *sorter = [[NSSortDescriptor alloc] initWithKey:date ascending:YES]; 
    [yourArrayName sortUsingDescriptors:[NSArray arrayWithObject:sorter]]; 

} 

希望它能幫助謝謝:)

+4

沒有,只是沒有。每次請求單元格時,爲什麼要對數組進行排序?那tableview會像瘋了一樣落後! – EmilioPelaez

+0

發生了什麼事情不起作用? –

+0

EmilioPelaez,但是這個人想排序他的table.let我給你一個例子:如果用戶在運行時創建新的單元格,那麼他/她也需要對該值進行排序。爲此,我在cellforrowat indexpath方法中使用了這個NSSortDescriptor –