Thursday, 15 May 2014

webview - iOS 8 Splash images after app launch -



webview - iOS 8 Splash images after app launch -

let me start saying follows know frowned upon apple, , rejected app store if submitted. non-issue not submitted in anyway. internal app.

with out of way now. need help in setting if, else , else if statements. before migration iphone 6 , 6+, current code works iphone5/5s , below screen sizes in loading , sending right image after app launch.

my goal here include iphone 6/6+ equation.

below relevant code pertaining doing this.

this loads images proper screen size.

//setting splash images #define is_iphone (!is_ipad) #define is_ipad (ui_user_interface_idiom() != uiuserinterfaceidiomphone) bool isiphone5 = cgsizeequaltosize([[uiscreen mainscreen] preferredmode].size,cgsizemake(640, 1136)); if (isiphone5) { // load iphone 5 splash uiimage *splash4inch = [uiimage imagenamed:@"default-568h@2x.png"]; self.splash4inchportrait = [[uiimageview alloc] initwithframe:cgrectmake(0.0f, 0.0f, 320.0f, 568.0f)]; [self.splash4inchportrait setimage:splash4inch]; [self.view addsubview:self.splash4inchportrait]; [self.view bringsubviewtofront:self.splash4inchportrait]; self.splash4inchportrait.contentmode = uiviewcontentmodescaletofill; } else if (is_ipad) { // load ipad splash uiimage *splashpad = [uiimage imagenamed:@"default-portrait~ipad.png"]; self.splashpadportrait = [[uiimageview alloc] initwithframe:cgrectmake(0.0f, 0.0f, 768.0f, 1024.0f)]; [self.splashpadportrait setimage:splashpad]; [self.view addsubview:self.splashpadportrait]; [self.view bringsubviewtofront:self.splashpadportrait]; self.splashpadportrait.contentmode = uiviewcontentmodescaletofill; } else { // load iphone 3.5" splash uiimage *splash35inch = [uiimage imagenamed:@"default.png"]; self.splash35inchportrait = [[uiimageview alloc] initwithframe:cgrectmake(0.0f, 0.0f, 320.0f, 480.0f)]; [self.splash35inchportrait setimage:splash35inch]; [self.view addsubview:self.splash35inchportrait]; [self.view bringsubviewtofront:self.splash35inchportrait]; self.splash35inchportrait.contentmode = uiviewcontentmodescaletofill; }

this hides/unhides said images depending on screen size loaded.

//get screen size cgrect screenbounds = [[uiscreen mainscreen] bounds]; if (uideviceorientationisportrait(self.interfaceorientation)){ //do portrait if (screenbounds.size.height <=480) { //code 3.5-inch screen splash35inchportrait.hidden = no; splashretina35inchportrait.hidden = yes; splash4inchportrait.hidden = yes; }else{ // code 3.5 retina inch screen splashretina35inchportrait.hidden = no; } }else{ // code 4-inch screen splash35inchportrait.hidden = yes; splashretina35inchportrait.hidden = yes; splash4inchportrait.hidden = no; }

this finish code image fading out.

- (void)webviewdidfinishload:(uiwebview *)webview { #define is_iphone (!is_ipad) #define is_ipad (ui_user_interface_idiom() != uiuserinterfaceidiomphone) bool isiphone5 = cgsizeequaltosize([[uiscreen mainscreen] preferredmode].size,cgsizemake(640, 1136)); if (isiphone5) { // loading iphone 5 [uiapplication sharedapplication].networkactivityindicatorvisible = no; nslog(@"didfinish: %@; stillloading:%@", [[webview request]url], (webview.loading?@"no":@"yes")); } else if (is_ipad) { // loading ipad [uiapplication sharedapplication].networkactivityindicatorvisible = no; nslog(@"didfinish: %@; stillloading:%@", [[webview request]url], (webview.loading?@"no":@"yes")); } else { // loading iphone 3.5" [uiapplication sharedapplication].networkactivityindicatorvisible = no; nslog(@"didfinish: %@; stillloading:%@", [[webview request]url], (webview.loading?@"no":@"yes")); } }

as can see, have working best of ability. need add together 6/6+ code.

or if knows improve simpler way of doing this, i'm ears.

the main goal preventing white flash after app loads. have tried delaying startup, since app webview, doesn't help @ all.

thanks reading, , help.

ios webview ios8 splash-screen

No comments:

Post a Comment