मैं पूरी तरह स्टंप्डया हूँ काम करता है, यहाँ की स्थिति है और उन्हें एक सूची के रूप में प्रदर्शित करता है। कोई समस्या नहीं।क्यों popViewController केवल हर दूसरे समय
बैटरी को संरक्षित करने के लिए, मैं सर्वर से अपना डेटा प्राप्त करने के बाद जीपीएस सेवा बंद कर देता हूं। यदि उपयोगकर्ता ऐप का उपयोग करते समय घूमता है और एक नई सूची चाहता है तो वह नेविगेशन नियंत्रक पर "ताज़ा करें" पर क्लिक करता है और सीएलएलोकेशन सेवा फिर से सक्रिय हो जाती है, सर्वर से डेटा का एक नया बैच पुनर्प्राप्त किया जाता है और तालिका को फिर से खींचा जाता है।
जबकि ऐप मेरे सर्वर से डेटा पकड़ रहा है, मैं एक कताई ग्लोब के साथ एक लोडिंग स्क्रीन लोड करता हूं जो कहता है "लोड हो रहा है, कृपया प्रतीक्षा करें" और मैं नेविगेशन बार को छुपाता हूं ताकि वे "बैक" नहीं दबा सकें।
तो, सर्वर से प्रारंभिक डेटा हड़पने बेकार ढंग से चला जाता है।
पहली बार जब मैं एक नया स्थान प्राप्त करने के लिए सभी कोड निष्पादित करता हूं, डेटा की एक नई सूची के लिए सर्वर को फिर से पिंग करता हूं और कोशिकाओं को अद्यतन करता हूं। हालांकि, तालिका दृश्य को लोड करने के बजाय इसे तालिका दृश्य के लिए नेविगेशन नियंत्रक बार को पुनर्स्थापित करना चाहिए, लेकिन फिर भी मुख्य विंडो में मेरा लोडिंग दृश्य दिखाता है। यह डिवाइस पर केवल सच है, सब कुछ सिम्युलेटर में पूरी तरह से ठीक काम करता है।
दूसरी बार जब मैं रीफ्रेश करता हूं तो फ़ंक्शन सामान्य रूप से काम करता है।
THIRD बार जब मैं रीफ्रेश करता हूं तो यह ऊपर की तरह विफल रहता है।
चौथा बार जब मैं ताज़ा करता हूं तो यह सामान्य रूप से काम करता है।
पांचवें बार जब मैं ताज़ा करता हूं तो यह ऊपर की तरह विफल रहता है।
इत्यादि, यहां तक कि ताज़ा भी सफल होता है और अजीब ताज़ा विफल रहता है। मैंने लाइन से अपनी सभी कोड लाइन पर कदम रखा और सबकुछ सामान्य रूप से निष्पादित होता प्रतीत होता है। मैं वास्तव में मूल निर्देशों पर कदम उठाना जारी रखता हूं और "कदम ऊपर" पर क्लिक करने की एक बड़ी राशि के बाद मुझे पता चला कि तालिका दृश्य वास्तव में सीएफआरयूनलूपन स्पेसिफिक में किसी बिंदु पर स्क्रीन पर प्रदर्शित होता है, लेकिन फिर मैंने "जारी रखें" पर क्लिक किया और मेरा लोडिंग व्यू स्क्रीन।
मैं बिल्कुल परेशान हूं। कृपया सहायता कीजिए!! आपकी अंतर्दृष्टि के लिए अग्रिम धन्यवाद।
Video of the strange behavior:
प्रासंगिक कोड:
RootViewControllerMethods
- (void)viewDidLoad {
//Start the Current Location controller as soon as the program starts. The Controller calls delegate methods
//that will update the list and refresh
[MyCLController sharedInstance].delegate = self;
[[MyCLController sharedInstance].locationManager startUpdatingLocation];
lv = [[LoadingViewController alloc] initWithNibName:@"Loading" bundle:nil];
[self.navigationController pushViewController:lv animated:YES];
[super viewDidLoad];
}
- (void)updateClicked {
//When the location is successfully updated the UpdateCells method will stop the CL manager from updating, so when we want to update the location
//all we have to do is start it up again. I hope.
[[MyCLController sharedInstance].locationManager startUpdatingLocation];
[self.navigationController pushViewController:lv animated:YES];
//LV is a class object which is of type UIViewController and contains my spinning globe/loading view.
}
-(void)updateCells {
//When the Core Location controller has updated its location it calls this metod. The method sends a request for a JSON dictionary
//to trailbehind and stores the response in the class variable jsonArray. reloadData is then called which causes the table to
//re-initialize the table with the new data in jsonArray and display it on the screen.
[[MyCLController sharedInstance].locationManager stopUpdatingLocation];
if(self.navigationController.visibleViewController != self) {
self.urlString = [NSString stringWithFormat:@"http://www.trailbehind.com/iphone/nodes/%@/%@/2/10",self.lat,self.lon];
NSURL *jsonURL = [NSURL URLWithString:self.urlString];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
NSLog(@"JsonData = %@ \n", jsonURL);
self.jsonArray = [jsonData JSONValue];
[self.tableView reloadData];
[self.navigationController popToRootViewControllerAnimated:YES];
[jsonData release];
}
}
CLController तरीके (यह इस tableview परियोजना के लिए आधार दृश्य है): मूल रूप से सिर्फ RootViewController
के लिए सीधे वापस सभी डेटा भेजता है// Called when the location is updated
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"New Location: %@ \n", newLocation);
NSLog(@"Old Location: %@ \n", oldLocation);
@synchronized(self) {
NSNumber *lat = [[[NSNumber alloc] init] autorelease];
NSNumber *lon = [[[NSNumber alloc] init] autorelease];
lat = [NSNumber numberWithFloat:newLocation.coordinate.latitude];
lon = [NSNumber numberWithFloat:newLocation.coordinate.longitude];
[self.delegate noteLat:lat];
[self.delegate noteLon:lon];
[self.delegate noteNewLocation:newLocation];
[self.delegate updateCells];
}
}
क्या आपने डीबगर में इन विधियों के माध्यम से कदम रखा है? यह देखने के लिए कि क्या ऑब्जेक्ट सृजन/हटाना आप अपेक्षा करते हैं, उस पर उपकरण चलाएं? क्षमा करें अगर मैं आपकी बुद्धि का अपमान कर रहा हूं, लेकिन चूंकि मुझे जल्दी से समस्या दिखाई नहीं दे रही है, तो अगली चीज़ जो मैं करूँगा वह आगे बढ़ना शुरू कर रहा है ... – mikeh
क्या पॉप ऐप छोड़ देता है? ऐसा लगता है कि आप वीडियो में जीपीएस फिक्स पाने के लिए ऐप को पर्याप्त समय नहीं छोड़ रहे हैं। स्थान मैनेजर विधियों में ब्रेकपॉइंट्स सेट करने का प्रयास करें। –