Animated gif in iPhone app - iphone

I want to show loading animation on my splash screen while loading application. Is it possible to add .gif animation in iOS if not then please suggest other ways that how can i show Progress HUD or series of images to look like loading of application.

You can't do animated graphics during the splash screen.
The splash screen is a static image that you supply, also referred to as a "Launch Image" (and I've linked the documentation for you, so you can see what I'm talking about).
If you want to do animation after the splash screen is dismissed, you're definitely welcome to do that, though.

just put this code and its working
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
splash = [[UIImageView alloc] initWithFrame:self.window.frame];
splash.image = [UIImage imageNamed:#"splash"];
hud = [[MBProgressHUD alloc] initWithView:splash];
[splash addSubview:hud];
hud.delegate = self;
[hud show:YES];
[self.window addSubview:splash];
[self performSelector:#selector(Load_FirstView) withObject:nil afterDelay:3];
[self.window makeKeyAndVisible];
return YES;
}

Subclass UIView and create your custom splash screen view. You need to load that SplashView in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions as subview of window object. Than create a timer of 3-6 seconds and remove that SplashView using removeFromSuperView method.
You can put any type of animation in your custom splash view but GIF animation is not supported.

My recommendation, which I implemented with good results, is to prepare both a launch image and a splash/loading screen, such that the launch image (maybe a logo) is identical to a UIImageView in the splash/loading screen. Then in the splash/loading screen, animate in a progress bar, increment the progress bar, and then launch the main app.
The trick is that the launch image is identical to the UIImageView in the splash/loading screen: to the user, it doesn't even look like a transition, it is so seamless.

Related

Add a 'global' UIView to an App with StoryBoard

Is there a way to create a global UIView as background with the use of a StoryBoard?
I am updating my App, and making iOS 5 as the minimum so I can use ARC and also StoryBoards.
However, in my App I used a MainView.xib which I loaded as my rootviewcontroller, and any subsequent view was transparent so the background (and a button/copyright notice) were always visible.
I don't seem to be able to figure out how to do this. I can add the Subview to the rootview controller in the AppDelegate, but as soon as I seque to the next view it is gone.
Any suggestions how this can be done?
One way you can do this by adding an image view as a subview of the window itself, and making the backgrounds of all the view controllers clear.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIImageView *iv = [[UIImageView alloc] initWithFrame:self.window.frame];
iv.image = [UIImage imageNamed:#"BlueGreenGradient.tiff"];
[self.window addSubview:iv];
return YES;
}

How should I replace the rootViewController of my main window?

I'm building an app that does a ton of setup when the app loads. As such, I have a loading view that displays some information to the user while the setup takes place...
MyLoadingViewController *loadingViewController = [[MyLoadingViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = loadingViewController;
[self.window makeKeyAndVisible];
.
.
//Setup code happens here
.
.
MyHomeViewController *homeViewController = [[MyHomeViewController alloc] init];
self.window.rootViewController = homeViewController;
When the setup code completes, I want to transition into my home screen. Is setting the rootVewController to the new home view controller the proper way to do that kind of a transition?
Thanks so much for your wisdom!
Yes, that's an ok way to do it -- you won't have any animation, but it should work fine. loadingViewController will be deallocated after you switch the root view controllers -- if that's not what you want, then you should create a property to point to it.
I sometimes cheat a little by having the ViewController that does all the loading display an image that is the exact same as the default.png on screen while it loads, then animate it out once complete.
For example in my LoginViewController I firstly display the default image in viewDidLoad, contact the server for auto login and then fade out the image once the app logins. The user never notices as he just sees the default image fade out once the app is ready.

iPhone :: Objective-C - AddSubview in my initial UIViewController ViewDidAppear

Hihi all,
This could very well be a silly question. I would like to navigate to my "Login View" upon the launching of my application. My current tries:
In my first UIViewController's viewDidAppear method, perform a [self presentModalViewController:LoginView animated:YES], this works, but the screen shows my main UIView first, then slide my LoginView from bottom to top. I can't find a way to perform it without the animation.
In my first UIViewController's viewDidAppear method, perform a [self.view addSubview:LoginView.view], it ends up with exc_bad_access error.
Basically, my requirement is to perform certain checks upon starting of the application, if a login is required, the application shall display the LoginView, otherwise, it should stay as my main UIView.
Please advice what is the best way of achieving this, instead of the above two silly methods. Thanks in advance!
:)
How about trying it in **- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {**
example :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
LoginViewController *aLoginViewController = [[LoginViewController alloc] init];
[self.navigationController presentModalViewController:aLoginViewController animated:NO];
[aLoginViewController release];
return YES;
}
your 1st step is a good way..
but to stop animation, its very simple. Set animated to NO.
[self presentModalViewController:aLoginViewController animated:NO];
once ur done with ur validation, just dismiss this aLoginViewController.
Instead of -viewDidAppear, it sounds like you want to use -viewWillAppear:, which will allow you to present your login controller before the initial view is displayed.
-presentModalViewController:animated is the right method to display your login controller's view.

iOS 4.2 Default.png loads then 1 sec of solid gray then my UIWebView appears

How do I make my app seamless from the default.png to my App? Should I load it somewhere else? FYI I only have an iPod Touch 2nd Gen for testing running 4.2.1(8C148) The 4.2 simulator does the same thing. 4.3 simulator works fine.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"index" ofType:#"html"]isDirectory:YES]]];
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
What is happening it is taking a few seconds before UIWebView fully loads its content. So whilst it is loading, you are seeing the background color of the web view. If you don't want the blank screen, I would advise showing an activity indicator, to show that something is happening.
Alternatively, set the webViews delegate as your self and only perform [self.window makeKeyAndVisible] in the webView' delegate message named `webView:didFinishLoad‘
The latter method is unadvisedly though, as your effectively delaying the start of your app for several seconds.
In viewDidLoad,
webView.delegate = self;
Now in a separate method, called -(void)webViewdidFinishLoad:(UIWebView *)theWebView
[imageView removeFromSuperview]
[imageView release]

How can I display a introduction modal view when the app start up?

I have a tab bar application and I want to display those views that most part of apps have, with the name of the company or the name of the app.
I've created the follow viewController
Introduction *introducao = [[Introduction alloc] initWithNibName:#"Introduction" bundle:nil];
I don't know where exactly should I insert the code to show the modal because I have a tab bar application:
[self.navigationController presentModalViewController:galeria animated:YES];
I've tried to insert these lines on appDelegate.. but didn't work.. somebody have an idea?
if you are trying to show a splash screen right when the application opens, you should use a Default.png image instead of a view controller showing an image. Check out the Apple Documentation on Human Interface Guidelines and Beginning iPhone Development.
First of all, you'll need to ensure that you have a navigation controller present to present the model view from. Otherwise in the above code you'll be messaging nil and nothing will happen. Then you'll want to put the presentModalViewController:animated: call in your app delegate's applicationDidFinishLaunching: implementation.
Thanks for all answers.. they were very useful to understand better the process..
I have found a solution that does exactly what I need! So if someone need to create those splash screens with a sequence of images it is very useful:
Just create a ImageView on the Delegates Header and do the following:
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
to control the duration of the splash screen:
[self performSelector:#selector(removeSplash) withObject:nil afterDelay:1.5];
To remove the splash:
-(void)removeSplash;
{
[splashView removeFromSuperview];
[splashView release];
}
so If you want to create a sequence of image just create a method to change the splashView.image.. and create a NSTIMER to call it..