내가 완전히 난처한 상황에 빠진 나는 다른 모든 시간을 작동합니까, 여기 상황이다 목록으로 표시합니다. 아무 문제 없습니다.왜 popViewController 만
배터리를 절약하기 위해 서버에서 데이터를받은 후 GPS 서비스를 끕니다. 사용자가 앱을 사용하는 동안 주위를 돌아 다니며 탐색 컨트롤러에서 "새로 고침"을 클릭하고 CLLocation 서비스가 다시 활성화되면 서버에서 새로운 데이터 배치가 검색되고 테이블이 다시 그려집니다.
앱이 내 서버에서 데이터를 가져 오는 동안 "로드 중입니다. 기다려주세요"라는 회전하는 지구본이있는 로딩 화면을로드하고 탐색 바를 숨겨 "뒤로"누르지 않습니다.
따라서 서버의 초기 데이터 수집은 완벽하게 진행됩니다.
처음 새로 고침을 누르면 모든 코드가 실행되어 새 위치를 가져오고 서버에 새 데이터 목록을 핑하고 셀을 업데이트합니다. 그러나 테이블 뷰를로드하는 대신 테이블 뷰의 탐색 컨트롤러 막대를 복원해야하지만 기본 창에서로드 뷰를 계속 보여줍니다. 이것은 기기에만 해당되며 시뮬레이터에서는 모든 것이 정상적으로 작동합니다.
두 번째로 새로 고침을 누르면 기능이 정상적으로 작동합니다.
내가 새로 고침 한 세 번째 시간은 위와 같이 실패합니다.
내가 새로 고침 한 네 번째 시간은 정상적으로 작동합니다.
내가 처음으로 새로 고침을 한 경우 위와 같이 실패합니다.
등, 심지어 새로 고침이 성공하고 홀수 새로 고침이 실패합니다. 모든 코드를 한 줄씩 밟았으며 모든 것이 정상적으로 실행되는 것 같습니다. 실제로 핵심 지침을 계속해서 실행하고 거대한 양의 "step over"를 클릭하면 테이블 뷰가 실제로 CFRunLoopRunSpecific의 일부 지점에서 화면에 표시된다는 것을 알았지 만 그 다음에 "계속"을 클릭하고 로딩 뷰를 넘겼습니다 화면.
나는 정말 당혹 스럽다. 도와주세요!! 당신의 통찰에 미리 감사드립니다.
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
앱을 탈퇴해도 팝업이 발생합니까? 비디오에서 GPS 수정 사항을 얻을 수있는 충분한 시간을 앱에 제공하지 않는 것처럼 보입니다. locationManager 메소드에서 중단 점을 설정하십시오. –