मेरे पास एक ऐसा एप्लिकेशन है जिसमें UITableView है। यह UITableView ऐपडिलेगेट में एक एनएसएमयूटेबलएरे (एक संपत्ति के रूप में) द्वारा पॉप्युलेट किया गया है। आप इसे ईमेल विंडो के रूप में सोच सकते हैं। यह उप-वर्गीकृत UITableViewCell में संदेशों को सूचीबद्ध करता है। जब कोई नया संदेश प्रकट होता है, तो मेरे पास सभी कोड किए गए हैं जो संदेश डाउनलोड करते हैं, डेटा को ऐपडिलेगेट के एनएसएमयूटेबलएरे में जोड़ता है जिसमें सभी संदेश होते हैं। यह कोड ठीक काम कर रहा है।[UITableView reloadData] के साथ क्या है?
अब, जब नया संदेश डाउनलोड हो जाता है और सरणी में जोड़ा जाता है, तो मैं निम्नलिखित कोड का उपयोग करके अपने UITableView को अपडेट करने का प्रयास कर रहा हूं, हालांकि - UITableView के प्रतिनिधि कार्यों को कॉल नहीं किया जाता है।
अजीब चीज तब होती है जब मैं अपने UITableView को ऊपर और नीचे स्क्रॉल करता हूं, प्रतिनिधि विधियों को आखिरकार बुलाया जाता है और मेरे सेक्शन हेडर बदल जाते हैं (वे उस खंड के लिए संदेश गणना दिखाते हैं)। क्या वे रीयल-टाइम में अपडेट नहीं करते हैं और रीफ्रेश ट्रिगर करने के लिए मेरी स्क्रॉलिंग की प्रतीक्षा नहीं करते हैं? इसके अलावा, अनुभाग में नया सेल कभी नहीं जोड़ा गया है !!
कृपया मदद करें !!
AppDelegate कोड:
[self refreshMessagesDisplay]; //This is a call placed in the msg download method
-(void)refreshMessagesDisplay{
[self performSelectorOnMainThread:@selector(performMessageDisplay) withObject:nil waitUntilDone:NO];
}
-(void)performMessageDisplay{
[myMessagesView refresh];
}
UITableViewController कोड:
-(void) refresh{
iPhone_PNPAppDelegate *mainDelegate = (iPhone_PNPAppDelegate *)[[UIApplication sharedApplication] delegate];
//self.messages is copied from appDelegate to get (old and) new messages.
self.messages=mainDelegate.messages;
//Some array manipulation takes place here.
[theTable reloadData];
[theTable setNeedsLayout]; //added out of desperation
[theTable setNeedsDisplay]; //added out of desperation
}
Dude मैं अपने दर्द महसूस करते हैं, एक ही मुद्दा यहाँ। –