UIToolbar Slide Out From Under UITabBar - iphone

I have an application that requires synchronization and I wanted to inform the user of the synchronization by sliding up a UIToolbar from underneath a UITabBar. I currently have:
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options
{
...
[self.tabBarController.tabBar addSubview:self.syncToolbar];
[self.tabBarController.tabBar sendSubviewToBack:self.syncToolbar];
...
}
However, the UITabBar appears to be transparent (as the tool bar shows even when it is behind). Any way I can get the UIToolbar to look like it is sliding up from underneath the UITabbar? Thnks!

Try using:
[self.tabBarController.view insertSubview:self.syncToolbar belowSubview:self.tabBarController.tabBar];
That should position your sync view where you want it.

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;
}

Animated gif in iPhone app

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.

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.

iPhone View Cutting Off

The view is created in interface builder, and is strangely cutting off at the bottom, and help or suggestions, is appreciated.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
Edit: I don't actually have a nib for the view controller, but instead a main window nib and a nib for two different views which are different themes.
Also if I use:
self.window.rootViewController = self.viewController;
it does not happen, but sadly this will crash in iOS 3.2 or below.
I experience the same problem, what I do is translating view 20 pixels down in ViewDidLoad then everything works fine. The problem surely is related to the statur bar but I do not know a solution other than this workaround.
To translate the view use this:
self.view.transform = CGAffineTransformMakeTranslation( 0, 20 );
In interface builder you need to check the dimensions of the view. You will see that it is too short (your height is probably set to 440, but it should be 460, or 480 if you don't have the status bar). This is probably why it appears to be cutting off.
Try enabling a simulated status bar in IB.

Why does an UIView in iOS/ appear too high up?

I'm relatively new to iOS programming. I have made a few basic apps before, and I'm getting back into it once again.
A problem I had a while back, and now is coming to haunt me is this.
When I create a new UIViewController subclass, myViewController (with xib) and add this code to get the add the view to the window, the contents always appear too high up, by the same width as the default/recommended left/right margin.
The code to add the view to the window is this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:#"MyViewController" bundle:[NSBundle mainBundle]];
[self setMyViewController:aViewController];
[aViewController release];
UIView *controllersView = [myViewController view];
[window addSubview:controllersView];
[window makeKeyAndVisible];
return YES;
}
For example, if I change the background colour of the view, I get a white strip at the bottom of the page when running in the simulator.
Any ideas?
Thanks
I don't think the problem is in that code. Although I guess you've done this already, it is probably a good idea to double check the .xib file. It may have an offset set in its position properties.
Also, it may be caused by the status bar not being set correctly. If you want to hide it, you can add an entry (UIStatusBarHidden -> true) in the info.plist file to set it to be hidden.
Either way check the dimensions of the .xib are the expected ones. And bear in mind the size of the status bar; the dimensions of the .xib file are different depending on whether the status bar is shown or not.