UIModalTransitionStyleFlipHorizontal doesn't work - objective-c

I try to change the modalTransitionStyle property of my modal view. Every style work except for FlipHorizontal. If I choose this, nothing happens.
I have an UINavigationController which should be flipped in.
Heres the code:
UINavigationController *loginNavCon = [[UINavigationController alloc] init];
loginNavCon.navigationBar.barStyle = UIBarStyleBlack;
// push login view
LogInViewController *liVC = [[LogInViewController alloc] initWithStyle:UITableViewStyleGrouped];
[loginNavCon pushViewController:liVC animated:NO];
[liVC release];
// show login view
loginNavCon.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.window.rootViewController presentModalViewController:loginNavCon animated:YES];
[loginNavCon release];
Thanks for your help.

Ok, I figured it out!
The point is to set it in the pushing UIViewController, not in the pushed one.
So in my example code it has to look like this:
UINavigationController *loginNavCon = [[UINavigationController alloc] init];
loginNavCon.navigationBar.barStyle = UIBarStyleBlack;
// push login view
LogInViewController *liVC = [[LogInViewController alloc] initWithStyle:UITableViewStyleGrouped];
[loginNavCon pushViewController:liVC animated:NO];
[liVC release];
// show login view
/** changed **/
self.window.rootViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
/*************/
[self.window.rootViewController presentModalViewController:loginNavCon animated:YES];
[loginNavCon release];

Related

Modal View Controller Size

I am trying to display a modal view controller, but keep the navigation bar displaying on the iPad. I've tried the different presentation styles but none work. Is it possible to size it, or display it within right on top of a certain view, instead above the whole view controller?
EDIT: Code added:
- (void)buttonPressed:(id)sender
{
RKWebViewController *webViewController = [[RKWebViewController alloc] initWithNibName:nil bundle:nil];
webViewController.request = [NSURLRequest requestWithURL:_link];
webViewController.webView.delegate = self;
webViewController.shouldDisplayDoneButton = YES;
webViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:webViewController animated:YES];
}
Use -
- (void)buttonPressed:(id)sender
{
RKWebViewController *webViewController = [[RKWebViewController alloc] initWithNibName:nil bundle:nil];
webViewController.request = [NSURLRequest requestWithURL:_link];
webViewController.webView.delegate = self;
webViewController.shouldDisplayDoneButton = YES;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController];
[webViewController release];
navController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:navController animated:YES];
[navController release];
}

ios navigation controller

I have this buttons controller with buttons xib. This buttons is included in my other views. The problem I have is button clicked navigation.
-(IBAction) gotoReport:(id) sender
{ NSLog(#"ll");
ReportStepOne *report = [[ReportStepOne alloc]init];
[self.navigationController pushViewController:report animated:YES];
[report release];
}
I could see the log message, but navigation doesn't work. I guess I should not use self?
appDelegate.H
UINavigationController *navCon;
appDelegate.M
navCon = [[UINavigationController alloc] init];
[navCon setNavigationBarHidden:YES];
Login *login = [[Login alloc] init];
[navCon pushViewController:login animated:NO];
[login release];
[window addSubview:navCon.view];
[self.window makeKeyAndVisible];
Your first example of IBAction is correct, it should pus the view. If it's not pushing, you need to check your XIB to make sure you have connected the correct button to this IBAction.
in your app delegate, do this instead:
Login *login = [[Login alloc] init];
// Make navController a property..
self.navController = [[UINavigationController alloc] initWithRootViewController:login];
//This is the key..
[[self window] setRootViewController:self.navController];
[self.navController setNavigationBarHidden:YES];
[login release];
[self.window makeKeyAndVisible];

navigationBar isn't showing when I put a UINavigationController in a UIPopoverController

I'm adding a UIViewController to a UINavigationController and then setting a UIPopoverController's view to the UINavigationController. Everything is working great except that I don't get a navigationBar at the top of the popoverController. I'm creating everything like this:
QueryViewController *puvc = [[QueryViewController alloc] autorelease];
UINavigationController *nc = [[UINavigationController alloc] autorelease];
[nc pushViewController:puvc animated:YES];
self.popUp = [[[UIPopoverController alloc] initWithContentViewController:nc] autorelease];
[self.popUp presentPopoverFromBarButtonItem:[self.toolbarItems objectAtIndex:0] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popUp.delegate = self;
I've tried to set navigationBarHidden = NO and it still doesn't show up. I have this code in my viewDidLoad of my QueryViewController:
self.contentSizeForViewInPopover = CGSizeMake(500.0, 500.0);
self.title = #"Queries";
Is there something that I'm missing to display the navigationBar? I am already in a UINavigationController for my main screen, could this be part of my problem?
QueryViewController *puvc = [[QueryViewController alloc] autorelease];
UINavigationController *nc = [[UINavigationController alloc] autorelease];
Maybe your code is wrong. Where is init methods?
You have to init both your QueryViewController and UINavigationController. For the second use initWithRootViewController method.
QueryViewController *puvc = [[[QueryViewController alloc] init] autorelease];
UINavigationController *nc = [[[UINavigationController alloc] initWithRootViewController:pucv] autorelease];
//[nc pushViewController:puvc animated:YES];
If you use initWithRootViewController it's not necessary to push puvc instance.
You could try also this (I like to release memory explicity, not using autorelease).
QueryViewController *puvc = [[QueryViewController alloc] init];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:pucv];
//[nc pushViewController:puvc animated:YES];
Then at the end of your code snippet remember to release puvc and nc.
[puvc release];
[nc release];
P.S. Check the code because I've written without XCode.

Title of tab bar items not showing

![I am creating a tab bar controller programmatically:
tabBarController = [[UITabBarController alloc] init];
FirstViewController* vc1 = [[FirstViewController alloc] init];
SecondViewController* vc2 = [[SecondViewController alloc] init];
vc1.title = #"Dallas";//[[NSUserDefaults standardUserDefaults] objectForKey:#"Citynamefrmhome"];
vc1.tabBarItem.image = [UIImage imageNamed:#"Dealss.png"];
vc2.title = #"My Vouchers";
vc2.tabBarItem.image = [UIImage imageNamed:#"nav_voucher_S.png"];
NSArray* controllers = [NSArray arrayWithObjects:vc1,vc2, nil];
tabBarController.viewControllers = controllers;
[self.view addSubview:tabBarController.view];
[vc1 release];
[vc2 release];
if I load it when the app starts, it looks great (look at figure 1):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
autoMagically = [[AutoMagically alloc] initWithNibName:nil bundle:nil];
//self.window.rootViewController = self.dummyView;
[self.window addSubview:autoMagically.view];
[self.window makeKeyAndVisible];
return YES;
}
if I load it when a button is clicked, the way i wanna do it, it looks like figure 2. See how the titles arent showing and the buttons seem to be getting cutoff:
- (void)LoadView
{
AutoMagically *autoMagic = [[AutoMagically alloc]
initWithNibName:nil bundle:nil];
self.autoMagically = autoMagic;
[self.view insertSubview:autoMagic.view atIndex:0];
[autoMagic release];
}
Does anyone know why this is behaving like this?]1
You can call
[[[self.parentViewController.tabBarController.tabBar.items objectAtIndex:/*a number based on what tab it was ex: 2*/]setTitle:#"string"];
in your -viewDidLoad or -awakeFromNib methods. It might be better to use the latter instead of the former.

UINavigationController Style

I created in code UINavigationController, but I want to change style to black translucent
FirstViewController *fvc = [[FirstViewControlelr alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] init];
navcon.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[navcon pushViewController:fvc animated:NO];
[self.window addSubview:navcon.view];
[self.window makeKeyAndVisible];
return YES;
But he doesn't change. Help me please!
I suspect it has something to do with the fact that you're accessing a navigation controller's navigation controller. Your navigation controller doesn't live in another navigation controller, so you're setting the bar style of something that isn't there.
You want this:
navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;
Also you can make a navigation controller and immediately initialize it with a root view controller so you don't have to push it in manually, like this:
FirstViewController *fvc = [[FirstViewController alloc] init];
UINavigationController *navcon = [[UINavigationController alloc] initWithRootViewController:fvc];
[fvc release];
navcon.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self.window addSubview:navcon.view];
[self.window makeKeyAndVisible];
return YES;
And yes, you forgot to release fvc in your own code.