Fade out Launch Image on 4 Inch iPhone screen - iphone

On launch, I am fading from my launch image to the application's interface. To achieve this, I am adding a UIImageView with "Default.png" and animating its alpha just before makeKeyAndVisible.
Should Default.png always return the device-specific (or resolution-specific) version of the launch image? Or should I be checking the screen's bounds and scale to pick the right one for the retina vs non-retina and 3.5 vs 4 inch screens?
I expected Default.png to behave much like other image resources - use the #2x version when supported (and the -568h version on the iPhone 5). But my experimentation in the simulator leads me to believe otherwise. Running the 4 inch simulator, the 3.5 inch image is used. This results in a splash image that does not extend to the bottom of the screen. The screenshot below shows the transition mid-animation.
Unfortunately I don't have each device so was unable to confirm if this is just a quirk of the simulator.
In short, I want to be sure that the retina image is used on retina devices, and the 4 inch image is used on 4 inch devices.

This is my code
- (BOOL) application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
[self.window makeKeyAndVisible];
[self _startLaunchAnimation];
return YES;
}
- (void)_launchAnimation {
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
UIImageView *launchImageView = (UIImageView*)[self.window viewWithTag:1000];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone
forView:self.window
cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(startupAnimationDone:finished:context:)];
[launchImageView setAlpha:0.0];
[launchImageView setFrame:CGRectMake(-60.0f, 0.0f, 320.0f, screenHeight)];
[UIView commitAnimations];
}
- (void)_startLaunchAnimation {
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
NSString *imageName = nil;
if (screenHeight == 568.0f) {
imageName = #"Default-568h.png";
} else {
imageName = #"Default.png";
}
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *launchImageView = [[UIImageView alloc] initWithImage:image];
[launchImageView setTag:1000];
[self.window addSubview:launchImageView];
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:#selector(_launchAnimation)
userInfo:nil
repeats:NO];
}

For the record, this is my version of #agassi_yzh's solution:
//fade from the launch image to the interface
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
NSString *imageFile = (screenHeight == 568.0f) ? #"Default-568h.png" : #"Default.png";
UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageFile]];
[self.window.rootViewController.view addSubview:splash];
[UIView animateWithDuration:0.5
animations:^{
splash.alpha = 0;
}
completion:^(BOOL finished) {
[splash removeFromSuperview];
}
];
//display the main window
[self.window makeKeyAndVisible];

The answer is you will have to explicitly load the device specific version of the image. This is custom animation and you cannot rely on Apple's Default whatever loading behavior to achieve what you want.
First make sure that you you are configured properly and the correct default load image is displayed on the devices (dont trust the simulator too much (aka I never even use the simulator its so buggy))
And then as previous commenters suggested load a view with your images.
Remember that the default image is going to be loaded and shown by the cocoa framework. All you can do is show a view afterward, if you try and do some of the admittedly clever hacks with the on load that are on the web you will find that they will always break in some way.
If you need a full screen image animated or not on iPhone 5 you need to load that image explicitly for the device thats all there is to it.

Yes, you provide Default.png and Default#2x.png, you even have to supply Default-568h#2x.png for the iPhone 5 4" screen.
You app will use standard, retina or big retina according to device but note that Apple discourage using the Default launch image as any intro animation sequence.
The trick you could use is to add an image view as the first screen of the app when it's launched and immediately fade it out, this will give the user the impression that the launch image is fading out even though the launch image is gone, and it's your image view taking over.
Look at the Launch image section of the Apple Custom Icon and Image Creation Guidelines:
Supply a launch image to improve user experience.
Avoid using your launch image as an opportunity to provide:
• An “app entry experience,” such as a splash screen
• An About window
• Branding elements, unless they are a static part of your app’s first
screen Because users are likely to switch among apps frequently, you
should make every effort to cut launch time to a minimum, and you
should design a launch image that downplays the experience rather than
drawing attention to it.

Related

google admob not clickable inside rectangle

I'm making one app in phone-gap so I've to deal in web-views only. In this app I need to put ads in the bottom of the screen. I'm using google admob for this. This generates floating ad window. I've put this window in bottom of the screen but problem is my webview content is hiding behind this window.
So, I've make one rectangle and add this google admob window in this rectangle. It solved my data hiding problem, but now it is not click able.
My code:
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
theWebView.backgroundColor = [UIColor blackColor];
CGRect viewBounds = CGRectMake([[UIScreen mainScreen] applicationFrame].origin.x, [[UIScreen mainScreen] applicationFrame].origin.y, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height-CGSizeFromGADAdSize(kGADAdSizeBanner).height);
self.view.frame = viewBounds;
CGPoint origin = CGPointMake(0.0,theWebView.frame.size.height);
bannerView_ = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin] autorelease];
bannerView_.adUnitID = #"___ADMOBID___";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
return [super webViewDidFinishLoad:theWebView];
}
How to make admob clickable inside rectangle (CGRect)???
Thanks in advance...
You're actually making the main view smaller, which basically - I guess - rescales its contents (including the webview Then you're placing the banner view right under the webview, but it'll show up anyways as you most probably have the clipsToBounds flag set to NO in your main view.
What you need to do is to make the webview (not the main view) smaller using CGRectGetHeight(self.view.bounds) - CGRectGetHeight(kGADAdSizeBanner) (and not the application frame) and then lay them both out accordingly.
Check the self.view.clipsToBounds flag and set it to YES whether in code or in IB in order to test correct behaviour, what you don't see in screen won't get any touches.

Display splash/loading screen longer on iPhone

I have a simple iPhone application that loads very quickly, so the splash screen only displays for a fraction of a second. Is there any way to control how long the splash screen displays? I have searched around, and have not found anything that seems like it would work. Do I have to create a subview with my splash image? How would I control its display time and switch between the subview and the mainview?
While I agree with the views expressed here and in the other question about why you should not "abuse" the default screen, it seems to me quite trivial to achieve this effect:
When starting up, simply put up a view that looks exactly like the splash screen and use an NSTimer to dismiss it. Really quite easy.
// viewDidLoad
[self performSelector:#selector(dismiss)
withObject:nil
afterDelay:yourTimeIntervalInSectons];
// dismiss
[self performSegueWithIdentifier:#"ID" sender:nil];
However, don't have the splash screen come on each time the application becomes active. I once did this for a very specific and useful purpose in the context of my app - but Apple rejected it. Hey, they even called me on Saturday evening to explain it to me.
While I agree with all that's been told here, I had to implement a splash screen with a timer once as well, so here's the code:
- (void)showSplashWithDuration:(CGFloat)duration
{
// add splash screen subview ...
UIImage *image = [UIImage imageNamed:#"Default.png"];
UIImageView *splash = [[UIImageView alloc] initWithImage:image];
splash.frame = self.window.bounds;
splash.autoresizingMask = UIViewAutoresizingNone;
[self.window addSubview:splash];
// block thread, so splash will be displayed for duration ...
CGFloat fade_duration = (duration >= 0.5f) ? 0.5f : 0.0f;
[NSThread sleepForTimeInterval:duration - fade_duration];
// animate fade out and remove splash from superview ...
[UIView animateWithDuration:fade_duration animations:^ {
splash.alpha = 0.0f;
} completion:^ (BOOL finished) {
[splash removeFromSuperview];
}];
}
Just call the function somewhere in your AppDelegate's -applicationDidFinishLaunching:withOptions: method
#asgeo1: code works just fine for me (I've used similar code in several projects). I've added an example project on my Dropbox for your convenience.
Don't do this and/or read why here
iOS Duration of Splash Screen (Default.png)
It does really make no sense to extend the duration of the Default.png.
Now, I completely agree with the above posts that you shouldn't do this, but if you still wish to it can be achieved very easily by adding the following to your AppDelegate.m.
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
sleep(2);
}
The "2" represents how many seconds to sleep for. It will accept values like ".5"

How to do transparent the launch image slowly.(alpha = 0.0;)

I can see the launch image(png at the root of the project, sized:320x480 pixels)  on the iPhone simulator and iPhone device.
And then,I want to do transparent it(the launch image) slowly .(alpha = 0.0;)
But I cannot do it.though I tried variously.
 
 
Thank you,
  Katsumi
Take a look at UIView animation methods. Method like animateWithDuartion should be sufficient for your goal. Your fade-out animation in the simplest implementation will looks like following:
[UIView animateWithDuration:1 animations:^(void){self.splashImage.alpha = 0.0f;}];
When the app launches you'll have to immediately create a new instance of the image via UIImageView and throw it on the main window. Then once you get access to that UIView you can use basic animation techniques to fade it out, such as -animateWithDuration:animations:.
Of course you'll want to setup some type of view below this, so you have your main app's content available right away.
Code sample:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// PLACE YOUR APP LAUNCH CODE HERE
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Default"]];
[self.window addSubview:imageView];
[imageView release];
[UIView animateWithDuration:2.0 animations:^{
imageView.alpha = 0.0;
[imageView removeFromSuperview];
}];
return YES;
}

How do I make an up to down animation when I click the add (plus) button on the iPhone?

How do I make a top to down or down to top animation when I click the add (plus) button on the iPhone?
If you are looking for the "Built In" API, Alex is correct. And that works perfectly well.
If you are looking to understand how do make your own animations, you have several options in Core Animation
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
but a great starting point is simply the UIView animateWithDuration
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html
you should also get to know the CGAffineTransform
putting this all together, here is an example of sliding a view onto screen from the bottom right, having it fade in at the same time. (I dont really know a situation where I would want to do that, but its an example).
I put this in the app delegate so its easy to simply "paste" into a new project. Normally you would not put any views of this nature directly into the window.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIWindow *w = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];;
self.window = w; //property defined in the .h file
[w release];
UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
v.backgroundColor = [UIColor redColor];
v.center=self.window.center;
v.alpha=0;
[self.window addSubview:v];
//if you ran the code to here, you would see a square in the center of the window.
//now lets move the square off (off screen) with a transform and then animate it back (on screen)
CGAffineTransform t = CGAffineTransformMakeTranslation(160+50, 240+50); //place the view just off screen, bottom right
v.transform=t;
//if you ran the code to here, you wouldnt see anything as the squre is placed just off screen, bottomr right
[UIView animateWithDuration:.5 //make the animation last .5 seconds
delay:.3 //wait .3 seconds before performing the animation
options:UIViewAnimationOptionCurveEaseOut //slow down as it reaches its destination
animations:^
{
v.transform=CGAffineTransformIdentity; //reset any transformation
v.alpha=1.0; //fade it in
}
completion:^(BOOL finished){} //nothing to do when it completes
];
[self.window makeKeyAndVisible];
return YES;
}
I think you're thinking of presentModalViewController; you can use it to present a new screen that slides up from the bottom of the screen.

iPhone, rotated + EAGLView, rotated =

...frustration. I want my game to be run only in landscape mode. I have added the appropriate key/value to the Info.plist file that forces the device orientation to be correct at launch.
I'm now trying to rotate the OpenGL coordinate space to match that of the device. I'm trying to use the code I found here, but it's not working. My test case draws a square at the center, and with all of that code included, I see nothing drawn; if I comment out the 2nd part (only setting the GL_PROJECTION matrix mode), the coordinate system does appear to be correct. But I'd like it rotated as well. I'm a little puzzled on how to do this, as well as setting up the view nib correctly as well. Tips, please?
Also, in the future, I'm going to be swapping out the EAGLView with another UIView subclass; is doing this going to require anything different?
Thanks!
randy
You have the plist set correctly.
Now make sure ALL your view controllers have the following:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight) ? YES : NO;
}
A child view without it can muck things up.
Also if you have a UINavigationController or similar you NEED to subclass it and implement shouldAutorotateToInterfaceOrientation because its dead stupid on its own and will default to portrait and ruin things.
Then for viewdidload
- (void)viewDidLoad {
[super viewDidLoad];
CGRect rect = [[UIScreen mainScreen] bounds];
rect.size.height = 320;
rect.size.width = 480;
rect.origin.x = 0;
rect.origin.y = 0;
glView = [[EAGLView alloc] initWithFrame:rect pixelFormat:GL_RGB565_OES depthFormat:GL_DEPTH_COMPONENT16_OES preserveBackbuffer:NO];
[self.view addSubview: glView];
[glView addSubview: minimapView];
//etc...
}