The first question: When using the Core Locatin frameworks, UI sometimes get stuck, ask a network problem? When positioning is asynchronous it?
Because they do not know whether asynchronous, so use a multi-threaded code is as follows:
dispatch_queue_t where = dispatch_queue_create ("where", nil);
dispatch_async (where, ^ {
_whereAmI = [[WhereAmI alloc] init] ;/ / to enter the location, location code
init starts at/ / The following is a note thread, refresh
UI'sdispatch_async (dispatch_get_main_queue (), ^ {
ModifyViewController * modifyViewController = [[ModifyViewController alloc] init];
modifyViewController.ispushed = YES;
[STHUnity sthPushViewController: self viewController: modifyViewController];
});
});
The second question: The first time you use GCD, I do not know of any? Give instructions. Because I use the above code, location could not have been started, when the code to remove a few of the GCD can start positioning, but that went back to the first question, the solution! ! !
Reply:
gcd is so used, the positioning will not start. Why did you start judging locate it? If it does not start, you can put init code Tieshanglai. Refresh ui main thread code that you do not understand is doing.
Reply:
My UI refresh is no problem, all of which is encapsulated in the class, and therefore, in this place unseen. init is on the LocationManager settings. Code is as follows:
- (Id) init
{
self = [super init];
if (self) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[_locationManager StartUpdatingLocation];
}
return self;
}
NOTE: If canceled GCD, init directly on the main thread, the positioning can be activated
Reply:
Why not start judging locate it? Of course, when one is positioned to have a purple arrow iphone and my positioning method, the print things, can be seen. Debug code executed when found [locationManager startUpdatingLocation]; but to no avail.
Reply:
Positioning is asynchronous callbacks, GCD is a delay in the operation of the secondary thread to do, do do surface in the main thread to update.
Positioned as an asynchronous callback mode, so you can directly put the main thread to start.
Done here without using GCD to deal with.
Reply:
You say I have tested, it is bad when the network positioning will lead UI refresh cards, so just put GCD where, in fact, when I was trying to locate on the program starts, but as a waste of resources ah
Reply:
Positioning itself is asynchronous, it should not be stuck UI, unless you do a lot of action when it receives the location information
Reply:
Start positioning code, no problem. Are you sure you allow this application to locate? Also upstairs that is right, location was originally asynchronous callback. No need to start in the background. Maybe you start to go into the background, ios think you do bad things, did not start positioning. As long as you are positioned inside the asynchronous callback function ui would not have good control card. (Ui are put into operation inside the main thread)
Reply:
I'm dealing with location information when parsing the latitude and longitude useless Apple directly using Google's API, require network access HTTP, to get a specific address information because returns json data, and many layers, so the processing of data It should account for a large memory
Reply:
Thank you for Kazakhstan
No comments:
Post a Comment