यदि आप कस्टम TableViewCells, जेनेरिक का उपयोग कर रहे हैं
[self.tableView reloadData];
जब तक आप वर्तमान दृश्य को छोड़ कर वापस नहीं आते हैं , तब तक इस प्रश्न का प्रभावी ढंग से उत्तर नहीं देते हैं । न ही पहला जवाब देता है।
विचारों को स्विच किए बिना अपनी पहली तालिका दृश्य सेल को सफलतापूर्वक लोड करने के लिए, निम्न कोड का उपयोग करें:
//For iOS 5 and later
- (void)reloadTopCell {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
NSArray *indexPaths = [[NSArray alloc] initWithObjects:indexPath, nil];
[self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}
निम्न ताज़ा विधि सम्मिलित करें जो उपरोक्त विधि को कहता है ताकि आप केवल शीर्ष सेल (या यदि आप चाहें तो संपूर्ण तालिका दृश्य) को पुनः लोड कर सकते हैं:
- (void)refresh:(UIRefreshControl *)refreshControl {
//call to the method which will perform the function
[self reloadTopCell];
//finish refreshing
[refreshControl endRefreshing];
}
अब आपके पास यह है कि, आपके viewDidLoadद्वारा निम्नलिखित को जोड़ा गया है:
//refresh table view
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:refreshControl];
अब आपके पास एक कस्टम रिफ्रेश टेबल फीचर है जो टॉप सेल को फिर से लोड करेगा। संपूर्ण तालिका को पुनः लोड करने के लिए, जोड़ें
[self.tableView reloadData]; अपने नए ताज़ा विधि के लिए।
यदि आप हर बार दृश्य स्विच करने पर डेटा को पुनः लोड करना चाहते हैं, तो विधि को लागू करें:
//ensure that it reloads the table view data when switching to this view
- (void) viewWillAppear:(BOOL)animated {
[self.tableView reloadData];
}
[NSArray arrayWithObject:]इसके बजाय उपयोग करना चाहेंगे ।