i have coded in appdelegate.m as following to change from currentview to UItable viewcontroller?but i am getting error,tab is a uitableview controller
tab = [interviewViewController alloc];
[viewController.view removeFromSuperview];
[viewController.view addSubview:tab];
[window addSubview:viewController.view];
YOu never initialize tab, and you addit to viewController. I'm not really sure what you're trying to do.
Do this:
tab = [[interviewViewController alloc] init];
[viewController.view removeFromSuperview];
[window addSubview:tab.vew];
Related
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
UINavigationController *nav_obj = [[UINavigationController alloc] initWithRootViewController:overviewViewController ];
[self.viewController presentModalViewController:nav_obj animated:YES];
[overviewViewController release];
[self.window makeKeyAndVisible];
return YES;
}
This code shows the blue bar of navigation controller, but no buttons on it.It seems like to be that the UINavigationController allocated as empty.
Who knows what problems is?
UPD:Archive http://www.mediafire.com/?lbjjvl6fcue2q18
Please help me, I'm new in objective-c
You need to create the button for it, for example:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:launcherView action:#selector(endEditing)];
self.navigationItem.leftBarButtonItem = doneButton;
[doneButton release];
The correct way to use a UINavigationController is to push view controllers on to it. That way they will be stacked and the navigation bar will be populated with a back button when it is case (i.e., when you can actually go back to a previous controller). You control the label that appears in the "back" button by defining the title of the controllers you push.
The technique shown in another answer (setting explicitly the button) is useful with defining the right button, if you ever need one.
You could try with this code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
UINavigationController* navigation = [[UINavigationController alloc] init];
[navigation pushViewController:overviewViewController animated:NO];
[overviewViewController release];
[window addSubview:[navigation view]];
[self.window makeKeyAndVisible];
return YES;
}
Instead of doing:
UINavigationController* navigation = [[UINavigationController alloc] init];
[navigation pushViewController:overviewViewController animated:NO];
you could also use initWithRootController, but to display the general case of how you push a view controller I preferred this one.
Notice that since you are pushing just a root controller, you should see no back button at the moment, but if you push a second view controller, then it will appear.
EDIT: I gave a look at your project. Summary of what you should try and do:
objects you need in your NIB: File's Owner (UIApplication), First Responder, FBFun App Delegate (iVkAppDelegate), Window (UIWindow); remove the rest;
File's owner delegate outlet is FBFun App Delegate;
FBFun App Delegate window outlet is Window.
With this simple setup (more or less what you have), use this code :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UINavigationController* navigation = [[UINavigationController alloc] init];
//-- MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
iVkViewController *overviewViewController = [[iVkViewController alloc] init];
overviewViewController.title = #"First";
[navigation pushViewController:overviewViewController animated:NO];
iVkViewController *overviewViewController2 = [[iVkViewController alloc] init];
overviewViewController2.title = #"Second";
[navigation pushViewController:overviewViewController2 animated:NO];
[overviewViewController release];
[window addSubview:[navigation view]];
[self.window makeKeyAndVisible];
return YES;
}
In the code above, as you notice, I instantiated twice your iVkViewController just to have a second controller to push onto the navigator.
Please, delete your existing app from the simulator, and the run this in order to see that the navigation bar is correctly created and you can go back from the second controller to the first one.
I removed usage of MainPageDialog, because the MainPage nib has many problems.
But I hope this skeleton is sufficient for you to go forward with your development.
You had missed the line as you are not adding view to window.Add this line in your code
[window addSubview:nav_obj.view];
I have an application containing a tab bar view and I have a login xib(login.xib) and its corresponding class files(LoginController) in the same application. I want that when my application launches, the login file should be loaded first and then once I click on the login button, my TabBar View should be launched.
Tried a lot many ways, but nothing worked. :(
Latest one is I tried putting the following code in the AppDelegate file at the end of application didFinishLaunchingWithOptions but facing an error:
loginController = [[LoginController alloc] init];
[window addSubview:tabcontroller.view];
[window addSubview:loginController.view];
[window makeKeyAndVisible];
return YES;
Error is "loginController" is undeclared.
Am I missing something. Please let me know if there are any other ways through which I can fulfill my requirement.
Also, on clickButton() inside the login, I am using event Touch Up Inside.
loginController = [[LoginController alloc] initWithNibName:#"login" bundle:nil];
[window addSubview:loginController.view];
[window makeKeyAndVisible];
Add following line when you have finished your login checks.
[window addSubview:tabcontroller.view];
Also, please check where the loginCont is used?
Thanks,
Just try using:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
UIView *indicatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
UIImageView *splashV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 20, 320, 460)];
[splashV setImage:[UIImage imageNamed:#"Default.png"]];
[indicatorView setBackgroundColor:[UIColor clearColor]];
[indicatorView addSubview:splashV];
[self.window addSubview:indicatorView];
//Take button check credentials on successful login call StopViewOnsuccessfullogin
}
-(void)StopViewOnsuccessfullogin
{
[indicatorView removeFromSuperview];
[splashV release];
[window addSubview:tabcontroller.view];
[window makeKeyAndVisible];
}
Hope that will work .....
One way to do it is to change the view controller property of the AppDelegate in Interface Builder to your new View Controller's XIB file.
Move the Tab Bar & associated view controllers into another nib, and only load that once the login screen is finished.
I'm wanting to have my app (on launch) load a view that I have created over the top of the original view, then when a button is clicked the top view will disappear and show the main view underneath. I know this is terribly simple, but how would I do this? Maybe push the view in viewDidLoad?
Use a navigation controller
MyViewController *myView = [[MyViewController alloc] init];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:myView];
My2ndView *secondView = ....
[navControl pushViewController:secondView animated:NO];
[window addSubView:navControl.view]
This can be incredibly simple. When the user clicks the button, just do this
secondViewController.view.hidden = YES;
Just add the two views in your delegate, and do that in your delegate.
If you prefer, just do it "in" secondViewController! self.view.hidden = YES;
It sounds like you're just doing something simple ...... no need to bother with a view controller.
You ask how to display the second view, just like this ..
-(BOOL)application:(UIApplication *)applic`ation
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[window addSubview:yourMainView.view];
[window addSubview:theTemporaryView.view]; // it goes on top
[window makeKeyAndVisible];
application.idleTimerDisabled = YES;
return YES;
}
-(BOOL)eliminateTempView // example, when the user clicks on the button
{
theTemporaryView.view.hidden = YES;
[theTemporaryView release];
}
Hope it helps!
i am using Following code in appdelegate.m file..but it did not work..?
OthersController *mm_OthersController = [[OthersController alloc] init];
[mm_OthersController tScreen];
[mm_OthersController release];
when i put break point, it goes to the function tScreen correctly....but i can get output..?if i call the method "tScreen" from view willappear of OthersController, it works fine....
the method in OthersController.m file
-(void)tScreen
{
[self.navigationController setToolbarHidden: NO animated: NO];
self.navigationController.toolbar.barStyle = UIBarStyleBlack;
}
any help pls......?
You should check whether you are doing this after adding the navigation controller to your window or before it.
Follow it like this:
[window addSubview:[navigationController view]];
OthersController *mm_OthersController = [[OthersController alloc] init];
[mm_OthersController tScreen];
[mm_OthersController release];
[window makeKeyAndVisible];
Hope this helps!
I am having a problem with the following code:
MyViewController *aController = [[MyViewController alloc] initWithNibName:#"MyView" bundle:nil];
self.myController = aController;
myController.title = #"List";
[aController release];
UINavigationController *bController = [[UINavigationController alloc] initWithRootViewController:myController];
self.rootNavController = bController;
[bController release];
[self.view addSubview:rootNavController.view];
When I run my program I get the problem where my view for myController is repeated along the y-axis all the way until the bottom of the screen. If I add myController.view to the root view it works ok. I only have the problem when I add myController as the rootViewController of my navigation controller.
Thanks in advance for any help!
The default navigation controller project template defines -applicationDidFinishLaunching this way:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
I realize you're instantiating your nav controller with alloc init rather than getting it from the XIB, however, it seems you ought to be adding it to the window's view tree.
Where is the code you are showing being called from?
The problem was that I did not specify the frame. Without specifying a frame using CGRectMake the view controller was just filling the entire space.
The line I needed was something like this:
rootNavController.view.frame = CGRectMake(0, 0, 320, 431);
Try this:
MyViewController *aController = [[MyViewController alloc] initWithNibName:#"MyView" bundle:nil];
self.myController = aController;
[aController release];
UINavigationController *bController = [[UINavigationController alloc] initWithRootViewController:myController];
self.rootNavController = bController;
[bController release];
[window addSubview:rootNavController.view];//<--What are you adding the navigationController to??? Another ViewController? TabController? or Window?
Then in the -(void)viewDidLoad method of MyViewController you can put
self.navigationItem.title = #"List";