Showing a custom view on entire project as a footer [closed] - iphone

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
My project architecture is a 'Master Detail' and i want to show a footer through out all the viewcontrollers or tableviewcontrollers that i navigate.
Please help me to find the way.

You have to add the custom view to the window as a subview. It will display in all screens of the project as a footer. It'll work perfectly unless your application support orientation.

you can add it this way and instead of UIView use your customView's object to achieve your goal.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
self.navMain = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = self.navMain;
[self.window makeKeyAndVisible];
UIView *viewFooter = [[UIView alloc] initWithFrame:CGRectMake(0, 431, 320, 49)];
[viewFooter setBackgroundColor:[UIColor redColor]];
[self.window addSubview:viewFooter];
[self.window bringSubviewToFront:viewFooter];
return YES;
}

You have to use one root controller with footer, and content view. Add other view controllers as child of root view controller and views as subview of the content view.
I wrote a post about it, you can find it here:http://antrix1989.blogspot.com/2013/09/uiviewcontroller-as-singleton.html

Related

need help understanding my error on my first iPhone app [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
applications expected to have a root view controller console
I'm trying to build the first app by following a book step by step but I guess I'm making a mistake.
it's a simple view app with just a logo nd a label and then I click build and run and it says "build succeded", but when ios simulator pop up the app is still blank, even if I go back home and ropen the app nothing change.
I see on the debug window this statement:
2012-10-26 04:07:03.376 welcome[1219:c07] Application windows are expected to have a root view controller at the end of application launch
AS far as I understand my app lacks of a root view controller but how can I implement it?
You specify the root view controller in your appDelegate class. It should look something like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:#"theNameOfMyXib" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
The important lines that you need to add are:
self.viewController = [[[ViewController alloc] initWithNibName:#"theNameOfMyXib" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
And under initWithNibName you put the name of the xib you created your interface in.
Note: Only add autorelease if your project isn't using ARC.

how to create a menu based ios application in xcode 4.2

I have no idea how to set up a menu based project in xcode 4.2.
Basically, the menu has 4 buttons in it each go to their own Navigation Controlled tableviews, but I'm not sure where to start with xcode 4.2.
In my previous application I have a main window that has the navigation controller in that, then there is a root view which sets up the 4 buttons and from there the tableview view controllers just get loaded into the navigation controller.
With xcode 4.2 I cannot seem to set the delegate of the main window, so I cannot figure this out.
So I am hoping someone understands what I am trying to do and can help me out or send me a example or tutorial or something. Thanks, any help would be greatly appreciated.
Here is how I setup my navigation controller and root view in the AppDelegate file. From there you can just add the buttons and so on just as before. If you mean to do it with the storyboard, it will be much easier. Let me know if I misunderstood the question though:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self managedObjectModel];
[self managedObjectContext];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.window.backgroundColor = [UIColor whiteColor];
RootViewController *controller = [[RootViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:controller];
[self.window setRootViewController:navigation];
[controller release];
[navigation release];
[self.window makeKeyAndVisible];
return YES;
}
You'll be fine with one UINavigationController. In your view with the 4 menu buttons just hide the UINavigationController.
Hide / Show UINavigationController

Add login screen infront of TabBar in IOS

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.

iPhone UITabBarController - Hard to click tab items

I'm having a really strange issue with my application that uses the UITabBarController.
First, I'm creating the tab bar programmatically and not using NIBs, ala:
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity: 3];
UINavigationController *nav;
VisitViewController *viewVisit = [[VisitViewController alloc] initWithTabBar];
nav = [[UINavigationController alloc] initWithRootViewController: viewVisit];
[localControllersArray addObject:nav];
[nav release];
[viewVisit release];
// ... other tabs, same format as previous
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
One other thing to note, is that in each view controller I'm adding, I'm calling "self.title = 'Tab Title';" to set the title text. I doubt that matters though.
Anyway, everything runs and displays fine -- the problem I'm having is that if I click on the bottom half of the tab image nothing happens. I have to click above the 50% mark to get the tab item to select and change the tabs.
If you look at tab bar applications, there's sort of a natural gradient break right down the middle horizontally. Basically anything below that line, I can't click to switch tabs. It's really annoying because on a device it makes you click the tab over and over until you get above that mark, and it feels very sluggish. On other tab apps like Twitter it works perfectly.
Any ideas?
I figured it out. I was using:
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
self.window = [[UIWindow alloc] initWithFrame:screenRect];
This must have been cutting off the clickable area of my views and slicing off the tab bar somehow. I changed it to:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
And it fixed my problem.

How to remove view from window?

I am using Cocos2D for my main framework. In some cases, I want Cocos2D to load a nib file and have that be the view:
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TargetPlayerViewController *myController = [[TargetPlayerViewController alloc]initWithNibName:#"TargetPlayerViewController" bundle:nil];
[window addSubview:[myController view]];
[window makeKeyAndVisible];
This works as expected, and shows the TargetPlayerViewController. Wonderful!
What I need to know is: once that view has been loaded, how can I have the view remove itself? I've tried a few different ways, but all of them result in the program crashing.
To test I have a button on the view set up which triggers this method:
- (IBAction)GTFOnow:(id)sender {
NSLog(#"GFTO");
//window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//[self.view removeFromSuperview];
//[window makeKeyAndVisible];
}
GTFOnow is a method in TargetPlayerViewController. When it is called, the current subview (that was called in the Cocos2D code above) should be removed from the window.
First of all, you shouldn't create a new window just because you want to remove a subview. Secondly, whatever else happens, this shouldn't cause the app to crash. In which class do you have the GTFOnowmethod? I suppose in the TargetPlayerViewController class?