What is superView in this case? (Tabbar APP) - iphone

I have a tabbar app with only 1 tab.
Here is my didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
OneDayViewController *oneDayView = [[OneDayViewController alloc] initWithNibName:#"OneDayView" bundle:nil];
tabBarController.viewControllers = [NSArray arrayWithObject:oneDayView];
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES; }
In any method in OneDayViewController, I have this code:
UIView *superView = [self.view superview];
Question is: what is superView now? UIView? UIViewController or ... I don't know (sorry about that)
P/S: I ask this because I want to remove OneDayView and add another view to tabbar.
Thanks you very much.

Your superview will be tabBarController.view...
(Earlier i have told it is window I was wrong...)
post the code that showing/pushing OneDayViewController... so we can get clear idea about the superview...

Related

iphone how to change viewcontroller

I need a login viewcontroller,when log in,entry the tabbar controller,and the view in tabbarcontroller should get the data from the login viewcontroller and change the navigationbar(draged from nib)'s title,for example,show the user's name.I did it like :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self.window addSubview:_tabbarController.view];
[self.window addSubview:_loginViewController.view];
[self.window makeKeyAndVisible];
return YES;}
I add two subview,so when I remove the loginviewcontroller,the root shows,in the LoginViewController.m,I did it like:
-(IBAction)ShangHaiButtonPressed:(id)sender{
[self.view removeFromSuperview];}
so how do i pass the value in login view to my tabbarcontroller?
Before remove from superview pass the value to tabbarcontroller
-(IBAction)ShangHaiButtonPressed:(id)sender{
[_tabbarController setUsername: [_loginViewController username]];
[_tabbarController setPassword: [_loginViewController password]];
[self.view removeFromSuperview];
}
I think it is not appropriate to remove the view directly. Why not use [_tabbarController presentModalViewController:_loginViewController]. and Dismiss it after button is pressed.

Most Elegant way to dismiss a presentModalViewController?

I have successfully shown a view upon launch that authenticates a user. Upon success, I want the presentModalViewController to no longer be visible and deallocate properly.
My code is as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the tab bar controller's view to the window and display.
[self.window addSubview:tabBarController.view];
Overview *overview = [[Overview alloc] initWithNibName:#"Overview" bundle:nil];
[self.tabBarController presentModalViewController:overview animated:YES];
[overview release];
[self.window makeKeyAndVisible];
return YES;
}
In your modal viewcontroller you need a piece of code doing:
[self dismissModalViewControllerAnimated:YES];

iPhone - App always starts with an empty white screen?

I can't get my iPhone app to display any of the content on startup.
Any idea what's wrong here?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
HomeViewController *t = [[HomeViewController alloc] init];
[self.window addSubview:t.view];
[self.window makeKeyAndVisible];
// I tried the following in case the problem is my
//view controller but nothing shows up at all
UISegmentedControl *t = [[UISegmentedControl alloc] init];
[self.window addSubview:t];
[self.window makeKeyAndVisible];
}
Unless your view controller implements loadView, you should load the view from a NIB file with initWithNibName:bundle:.
A segmented control should be initialized with initWithItems:. You should also assign a frame to the control.

iphone, addSubview show view too high up, how do I move to down?

I'm using addSubView twice in my app and both times it adds the view too high up the view, its off the screen at the top. See below... I have load the views like this as I nothing else works, cause me problems.
I just don't understand why they are showing off the screen?
What do I need to do to fix this ?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:rootController.view];
[window makeKeyAndVisible];
lvc = [[GettingStartedViewController alloc]
initWithNibName:#"GettingStartedView" bundle:nil];
[window addSubview:lvc.view];
return YES;
}
And in my GettingStartedView ...
- (IBAction) showHelp:(id)inSender {
theController = [[HelpViewController alloc] initWithNibName:#"HelpView"
bundle:nil onPage:HelpPageGettingStarted];
[self.view addSubview:theController.view];
}
Set the location:
rootController.view.frame = CGRectMake(0, 20, 320, 460);
Check the wantsFullScreenLayout property of your root view controller, make sure it's not set.

Problem adding a UIView created from a NIB to the window and offsetting to compensate for the menu bar

I have noticed that when you create a new xcode project as a view based application it creates a view NIB and when that NIB is loaded it loads below the menu bar. I am trying to create a window based application and programmatically add a view to the window, but the view gets loaded underneath the menu bar so part of the view is being obstructed.
i have tried
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
MYViewController *viewController = [[MYViewController alloc] initWithNibName:#"MYViewController" bundle:nil];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
and i have also tried changing the "wantsFullScreenLayout" property of the view controller to FALSE;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
MYViewController *viewController = [[MYViewController alloc] initWithNibName:#"MYViewController" bundle:nil];
viewController.wantsFullScreenLayout = NO;
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
any help would be appreciated
Thanks
found it!
[MYViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];