0

我有一個單獨的對象,它具有ivar NSMutableArray,它將全局圖像保存到應用程序中。我有一個UITableViewController類代表圖像附加到消息。我想要做的下一個:當用戶從相機膠捲選擇圖像,他們被添加到該單身人士的數組。我想立即重新加載我的UITableViewControllertableview以顯示這些新消息。我怎樣才能實現這個?我應該使用Key-Value Observing來解決這個問題嗎?如果是的話,我該怎麼做? (我應該通知何時將新對象添加到數組中)。或者可能有其他更正確的方法?當我向另一個類中的NSMutableArray添加一個新元素時如何重新加載UITableView?

+0

當添加對象陣列通話[tableview中reloadData] –

回答

1

我確切地知道什麼ü需要做。 Download this Demo僅供參考。

它具有委派方法

- (void)imagePicker:(GKImagePicker *)imagePicker pickedImage:(UIImage *)image{ 

    // add your code here for adding image to Your mutable array and then Reload your tableView. 

     } 
0

當你想要重新加載視圖時,發送NSNotification怎麼樣?

UITableView可以接收通知並重新載入數據。

0

新增通知中類有表

[[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(actionremovecalender:) 
               name:@"subMitReport" 
               object:nil]; 
-(void)actionremovecalender:(NSNotification *)notification 
{ 
    //table relaod code 
} 
call to another class 
[[NSNotificationCenter defaultCenter] postNotificationName:@"subMitReport" object:self]; 
相關問題