Three20 TTLauncher Issues - iphone

So, I'm having some issues with my implementation of the Three20 TTLauncherView. I am using their code, not a fork (although I have heard of rodmaz's version), and I can't get it to work properly. This is what my app looks like.
alt text http://img709.imageshack.us/img709/8792/screenshot20100715at409.png
I removed the icon image, that's not the issue. The issue is, at the top there is no Navigation bar at all, and I believe also causes the white strip at the bottom, which appears to have the same dimensions as a Nav Bar. I've spent quite a while looking through their code and can't figure this out at all. It looks like their Navigation bar (as seen in their Catalog example app) stems from the TTTableViewController, or something further up. However, my app starts like the Facebook app does, not into a table, but into the TTLauncherView. So... how do I get the Navigation bar into my TTLauncher view, if it goes "App Delegate -> TTLauncherView Subclass"
Thanks for your help!
Edit:
Added the code I used. I put this in my app delegate, wrapping my first view with the UINavigation Controller, and it worked just as I wanted!
MainViewController *aController = [[MainViewController alloc] initWithNibName:nil bundle:nil]; //my Main view
self.mainViewController = aController;
[aController release]; //release for Memory Management
self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
UINavigationController *navigationController = [[UINavigationController alloc] init];
[navigationController pushViewController:self.mainViewController animated:NO]; //Gets the main view on the screen
[window addSubview:navigationController.view];

You simply wrap the view with a navigation bar before you push the new view. As an example, here is a snippet of my code where I present a modal view controller with a navigation bar.
- (IBAction) showNewNavView: (id) sender
{
// Present it as a modal view and wrap the controller in a navigation controller to provide a navigation bar for the Edit and Save buttons
ModalViewController *addController = [[ModalViewController alloc] initWithNibName:#"ModalViewController" bundle:nil];
addController.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[addController release];
}
If you want to add any buttons or set the title of it, you need to do that in the viewDidLoad method of the view that you are pushing (i.e. your TTLauncher view)

Related

How to load a UICollectionViewController on clicking a button in the navigation bar?

I have a class, DisplayOptViewController, which is a subclass of UICollectionViewController.
I want to display this CollectionViewController when the user clicks a button in the Navigation Bar on my current page. I am able to load the CollectionView on button Click but the Navigation Bar is not coming. I want the user to be able to see a back button in the navigation Bar and clicking the button should take him back to the current page.
I tried to do this via storyboard as well as programmatically. When I try this via the Storyboard, the ViewController itself is not displayed and when I create the view controller object programmatically, I am not getting the Navigation Bar. Any idea how to to this?
I tried to add this code to my viewDidLoad method in DisplayOptViewController:
UINavigationBar *navBar=[[UINavigationBar alloc] init];
[[self navigationController] setNavigationBarHidden:NO animated:YES];
[self.navigationController.navigationBar addSubview:navBar];
But the Navigation Bar still didn't come. Kindly help.
update
I am loading the UICollectionView here
UICollectionViewFlowLayout *aFlowLayout = [[UICollectionViewFlowLayout alloc] init];
[aFlowLayout setItemSize:CGSizeMake(140, 50)];
[aFlowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
DisplayOptViewController *vc=[[DisplayOptViewController alloc] initWithCollectionViewLayout:aFlowLayout];
[self presentViewController:vc animated:YES completion:nil];
You have a few things that i question,
[self.navigationController.navigationBar addSubview:navBar];
you are adding a navigation bar to a navigation bar.... do this instead
[self.navigationController setNavigationBar:navBar];
second
[self presentViewController:vc animated:YES completion:nil];
you are presenting the controller.... not pushing/poping it....
[self.navigationController pushViewController:vc animated:YES];
try that in when you do it programmatically
as for the storyboard maybe you don't have the segues set up correctly, or properties not set right or something... but i can't debug it like this
If you have a navigation based project, then you have to initialize the navigation controller in the app delegate itself. Try the code below to make the navigation bar visible,
In application didFinishLaunchingWithOptions method,
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[self viewController]];
[[self window] setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
Now your navigation bar will appear.

How to keep UINavigationController's UINavigationBar transparent when modally presenting a controller?

I've got a fullscreen view inside of a UINavigationController. When I attempt to present a modal view on top of it, the UINavigationBar changes to opaque, pushing down the content, before the modal view animates. How do I keep this from happening?
ContextMenuViewController *cmvc =
[[ContextMenuViewController alloc] initWithNibName:nil bundle:nil];
[cmvc setDelegate:self];
UINavigationController *navControl =
[[UINavigationController alloc] initWithRootViewController:cmvc];
[cmvc release];
[navControl.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
[self.navigationController presentModalViewController:navControl animated:YES];
[navControl release];
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackTranslucent
animated:NO];
The UINavigationController's root view does not have any transparency (status bar nor UINavigationBar), only the pushed controllers have the transparency.
I created a video of the issue: http://www.youtube.com/watch?v=KSFvzTR5Ejk
Example source at: http://cl.ly/7lu2
I tried your code in a very small test project and didn't see the issue you describe. I suggest you do the same thing. Start with the Navigation-based Application template. In the main nib, check the navigation controller's Wants Full Screen and Resize View From Nib, and make its nav bar transparent. In the root view controller's nib, put a button that you can respond to, set up the action, and paste in your code. Create the ContextMenuViewController class; there is no need to give it a nib.
Run the app and press the button. The modal view slides into place, with a transparent nav bar, without affecting the transparency of the nav bar that already exists and without moving the existing content.
So now, once you've proved to yourself that it works in this simple project, it's just a question of locating what you're doing different from that in the real project.
Try setting the bar styles during viewDidLoad for the root View Controller.
HERE YOU GO )
OptionsViewController *detailViewController = [[OptionsViewController
alloc] initWithNibName:#"OptionsViewController" bundle:nil];
UINavigationController *optionsController = [[UINavigationController
alloc] initWithRootViewController:detailViewController];
[detailViewController release];
optionsController.navigationBar.translucent = YES;
optionsController.navigationBar.opaque = YES;
optionsController.navigationBar.tintColor = [UIColor clearColor];
optionsController.navigationBar.backgroundColor = [UIColor
clearColor];
optionsController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:optionsController animated:YES];
[optionsController release];

view controller does not load with content

I have a button that when clicked shows a view controller. The code for that event is:
and my view controller looks like this:
note the segmented control and background image.
Here is my h and m files of my view controller in case you need them:
when I run my app here is how that view control looks on my iPad:
why do the background image and segmented control do not appear? why are contents not being loaded? It looks like another view controller is being loaded but I have already make sure that I am placing the correct name in the string for the view controller.
- (IBAction) vaClick
{
imgVa.image = [UIImage imageNamed:#"bt-valores.png"];
UIViewController *control = [[NuestrosValoresViewController alloc] initWithNibName:#"NuestrosValoresViewController"
bundle:nil];
UINavigationController *navControl = [[UINavigationController alloc]
initWithRootViewController:control];
[self presentModalViewController:navControl animated:NO];
[navControl setNavigationBarHidden:YES];
[control release];
[navControl release];
//UINavigationController *navControl = [[UINavigationController alloc]
//initWithRootViewController:control];
//[self presentModalViewController:navControl animated:NO];
}
should I release it like this? sorry I basically have to translate a power point presentation to an app therefore I know very little about objective-c. thanks for the help and sorry for the dumb question.
You're not setting the root view controller of your UINavigationController.
Use this line instead when initializing the navigation controller:
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:control];
You'll also want to release navControl after you present it modally. I'll write out the code for you if you post your code instead of using screenshots.

UINavigationBar refuses to show in Modal View Controller

I am loading a Modal view controller using the following code in my RootViewController:
[self.navigationController presentModalViewController:accountViewController animated:YES];
In the accountViewController xib file, I have set a navigation bar. My MainWindow.xib and RootViewController.xib also have the navigation bar setup correctly. Additionally, my app delegate has setup the navigation controller (I assume) correctly:
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[window addSubview:navigationController.view];
However, when I load my accountViewController the UINavigationBar is nowhere to be seen. Is it not possible to show a UINavigationBar in a modal view? I was planning to use it to hide the back button, and add a right button...
sha's answer is correct, but I'm giving my own answer to expand on it with a code example to make it clear.
You probably want something like:
- (void)showAccountViewController
{
AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:#"AccountView" bundle:nil];
...
// Initialize properties of accountViewController
...
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[accountViewController release];
}
You need to push not viewController but navigationController that has viewController inside.
You can also set the presentation style in the Attribute Inspector to "Current Context". Modal View will not cover the Navigational Bar.

pushViewController Not Displaying UIView/Nib with tabbar and nav bar

I'm relatively new to objective c but not programming and am stuck with my iphone app.
I created a nav based app with both a navbar and a tab bar controller. I set the tab bar as the root controller. I'm able to switch between each tab without any issues to various UIViews and UITableViews.
My issue is that in one of my UITableViews that I call from the TabBarController, didSelectRowAtIndexPath function is suppose to display a new UIView. The below code does not give any errors and runs fine but does not show the new Nib.
if(newViewController == nil) {
NSLog(#"yes nil");
BookViewController *aNewViewController = [[BookViewController alloc] initWithNibName:#"BookOptionView" bundle:nil];
self.newViewController = aNewViewController;
[aNewViewController release];
}
BookAppDelegate *delegate = (BookAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.appNavBar pushViewController:newViewController animated:YES];
Now when I do the below, it works fine but it gets rid of the nav and tab which I'm assuming because its a modal call instead of pushing the view controller.
BookViewController *screen = [[BookViewController alloc] initWithNibName:#"BookOptionView" bundle:[NSBundle mainBundle]];
screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:screen animated:YES];
[screen release];
Any ideas why I can't get the View Controller to push correctly? In my application delegate file, I declared an AppNavBarController object (inherit from UINavigationController) called appNavBar.
Any help would be appreciated!
If you want to present your view as a modal view with nav controller, you can do it as below:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
[self presentModalViewController:navigationController animated:YES];
Also, from what I see, you have your navcontroller in your appdelegate. So I guess you are using a global navcontroller for all your tab views, which ideally shouldn't be the case. Your navcontroller should be within your tab controller and preferably you need to have different nav controllers in different tabs.
I actually found my answer. I'm not sure I understand why my code above doesn't work but the following accomplishes what I want:
[self.navigationController pushViewController:newControllerName animated:YES];