ios - SKStoreProductViewController showing up with delay -
i use in app skstoreproductviewcontroller
. shows correctly, few seconds of delay, slows down user experience.
is there wrong in code ? or should inform user vc loading ? because right 1 can believe nothing happening after pressing button (which triggers following code) :
-(void)launchapp:(id)sender { // recall on main thread if necessary if (![nsthread ismainthread]) { [self performselectoronmainthread:@selector(launchapp:) withobject:sender waituntildone:no]; return; } // initialize product view controller skstoreproductviewcontroller *storeproductviewcontroller = [[skstoreproductviewcontroller alloc] init]; // configure view controller [storeproductviewcontroller setdelegate:self]; [storeproductviewcontroller loadproductwithparameters:@{skstoreproductparameteritunesitemidentifier : @"*********"} completionblock:^(bool result, nserror *error) { if (error) { nslog(@"error %@ user info %@.", error, [error userinfo]); } else { // present store product view controller [self presentviewcontroller:storeproductviewcontroller animated:yes completion:nil]; } }]; }
the delay caused because present viewcontroller after products have been loaded sucesfully.
you can put call presentviewcontroller:animated:completion:
outside of block called after products have been loaded. in case controller presented empty, , filled after products have been loaded.
something along lines:
skstoreproductviewcontroller *storeproductviewcontroller = [[skstoreproductviewcontroller alloc] init]; // configure view controller [storeproductviewcontroller setdelegate:self]; [storeproductviewcontroller loadproductwithparameters:@{skstoreproductparameteritunesitemidentifier : @364709193} completionblock:^(bool result, nserror *error) { if (error) { nslog(@"error %@ user info %@.", error, [error userinfo]); } else { } }]; // present store product view controller [self presentviewcontroller:storeproductviewcontroller animated:yes completion:nil];
or create "popup" view shows activity indicator while controller loads content.
or use [uiapplication sharedapplication].networkactivityindicatorvisible = yes;
there couple of ways handle this.
Comments
Post a Comment