0
트윗을 보내기 전에 latitude.text 및 longtitude.text가 채워지기를 기다리고 싶습니다.이 코드는 잘 작동하지만 locationManager에 tweeting 부분을 넣지는 않을 것입니다. 트윗을 보내지 않고 현재 위치를 업데이트하려고합니다. 이렇게하지 않고 트윗을 보내기 전에 txt가 채워지는 것을 어떻게 확인할 수 있습니까?트위터 전에 CLLocationManager가 끝날 때까지 기다려야합니다
- (IBAction)update {
latitude.text [email protected]"";
longitude.text [email protected]"";
locmanager = [[CLLocationManager alloc] init];
[locmanager setDelegate:self];
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D location = [newLocation coordinate];
latitude.text = [NSString stringWithFormat: @"%f", location.latitude];
longitude.text = [NSString stringWithFormat: @"%f", location.longitude];
TwitterRequest * t = [[TwitterRequest alloc] init];
t.username = @"****";
t.password = @"****";
[twitterMessageText resignFirstResponder];
loadingActionSheet = [[UIActionSheet alloc] initWithTitle:@"Posting To Twitter..." delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[loadingActionSheet showInView:self.view];
[t statuses_update:twitterMessageText.text andLat:latitude.text andLong:longitude.text delegate:self requestSelector:@selector(status_updateCallback:)];
[email protected]"";
}
정말 복잡한 것처럼 보입니다. 당신이 말하는 것을 전혀 알지 못합니다. (방금 3 일 전에 객관적인 C를 배우기 시작했습니다.) 다른 위치 관리자 functon을 사용할 수 있습니까? – user295944
정말 그렇게 복잡한 것은 아닙니다. "다른 위치 관리자 기능"이 무슨 뜻인지는 모르겠다. 위치 관리자에서 코드를 옮기고 싶다고 생각 했으므로 그렇게 할 수있는 방법을 제공했습니다. 또한 리스너를 사용하여 앱의 다른 부분에서 리스너를 등록하거나 제거 할시기를 결정할 수 있습니다. 몇 가지 Objective-C 개념 (프로토콜과 같은)을 이해하는 데 시간을 투자하고 솔루션을 생각해내는 데 도움이 될 것이라고 제안합니다. –