Add a new iPhone View above everything, including the navigation bar - iphone

In an application I'm developing, everything starts from a navigation controller, which then loads up several pages.
My question is, how can I load up a new view ABOVE this? The closest I've got is to do this in the App Delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self checkAndCreateDatabase];
[self readDataFromDatabase];
[window addSubview:[navigationController view]];
// Add this
[window addSubview:[newViewController view]];
[window makeKeyAndVisible];
return YES;
}
However this will load the view half way across the screen with no way of having it start at (0,0). Do anyone have a better suggestion?
Thanks

You can show regular views on top of everything by showing it as a modal view. Here is a sample project. http://dl.dropbox.com/u/3656129/ModalViewExample.zip

Related

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.

How to push Splash Screen Loading View till its loaded

I have tried this for past few days and have not got any success yet.
I am loading various XML Data once the application is launched. But currently I have not loaded any loading page to show the loading of the page. I would like to add a page which shows loading of my data and then push that loading view page to the tab bar controller page.
Does anyone have any example or any idea to share it, will be really helpful.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
[navController.navigationBar setTintColor:[UIColor blackColor]];
LoadingViewController *lvc = [[LoadingViewController alloc] initWithNibName:#"LoadingView" bundle:nil];
// Adding the modal view controller to loading View controller on Main Tab bar controller. Hope its correct
[self.rootController presentModalViewController:lvc animated:YES];
[window addSubview:rootController.view];
[window makeKeyAndVisible];
[self URL];
[lvc release];
return TRUE;
}
There are lots of ways to do something like this. One option is to create a viewcontroller that shows your loading view. add your tab bar controller to the window. Then present the loading view controller as a modal view controller over the tab bar controller. Then start your xml parsing, and dismiss the modal controller when the parsing is finished.

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.

Shake detection with using IBuilder or Load View without IBuilder [duplicate]

This question already has answers here:
iPhone Shake event not properly working
(2 answers)
Closed 2 years ago.
I am writing some application (let's say game - 1 view no cocoa controls) which needs to detect shakes.
As beginner with IOS have started with default openGL template (new one). Application works.
I have decided to add shakes. "motionBegan" don't work on "EAGLEview", so I have created view controller. Touches worked but "motionBegan" still not worked. (same like "viewDidAppear")
I thought that somehow IBuilder file is overlapping it.
So I have decided to resign from my IBuilder file and move forward without.
What I have now is:
main.m
int retVal = UIApplicationMain(argc, argv, nil, #"SimplePianoAppDelegate");
SimplePianoAppDelegate.m
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];
viewController = [[InputControler alloc] init];
glView=[[EAGLView alloc] initWithFrame:window.bounds];
glView.hidden=NO;
viewController.view=glView;
[window bringSubviewToFront:glView];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[glView setMultipleTouchEnabled:YES];
[glView performSelectorOnMainThread:#selector(mainAppLoop) withObject:nil waitUntilDone:NO];
With this code touches and motions worked but I don't see anything. (just white screen) :(
I am sure that some of the lines above are not necessary, but I am trying all possible options. What is strange is that no matter if I create my glView or not "loadView" in viewcontroller is not called.
Thank you for help in advance.
Mariusz
while I have connected view outlet in view with controller it started to work... with this:
[self becomeFirstResponder]

Two UITabBarControllers and Autorotation

I have two UITabBarControllers in my mainwnidow.nib wired to my appdelegate.
In my app delegate, I can load either one:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//either
[window addSubview:tabBarController.view];
//or
[window addSubview:tabBar2Controller.view];
[window makeKeyAndVisible];
}
and autorotation works.
If I add both (with the expectation to swap between them later):
[window addSubview:tabBarController.view];
[window addSubview:tabBar2Controller.view];
then autorotation stops working...everything is always portrait.
Thanks in advance for any tips...
Hmmm, I don't like this design. Typically windows should only have one subview.
Add another view controller that holds the instances of your tabBarControllers, and do the switching from there. That will fix your problem.
After thinking it through more, I realized I could just switch out the tabBarController.viewcontrollers array.
In IB I added both sets of tabs to a single tabbar, and then the appdelegate seperates them into two arrays and swaps between them as needed.
It works fine, but the jury is still out on whether the UI is effective