Archive for the ‘Code’ Category

Date Formatting

I found this useful in working with NSDateFormatter:

http://unicode.org/reports/tr35/#Date_Format_Patterns

Done Button Issues

I made a quick video here:

Which sums up the issue nicely.  Basically, the notifications which we create in one view affect the entire app, regardless of view.  This means the Done button will appear in all the views, and all the keyboards no matter what.

Edit:

After looking around, I found that if you are running a multiview application and don’t want to have Done Buttons appearing all over the place, you can stop the notifications by adding this:

-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

Some Code For the World

Also titled: One hack to get around UINavigation Controller not supporting orientation changes correctly.

I think this is a well documented bug, discussed here, and here, and here.  Basically, if you are using a UINavigation Controller in your app, the controller completely ignores all of your orientation preferences.  This isn’t an issue if you only use portrait, or if you only use landscape, or if you support both in all your views, but if one of those is false; you’re in trouble.  In MTG Arcanum, Multiplayer (for now) is strictly landscape.  It gives us more room left to right, which I think is important.  I’m working on enhancing Multiplayer, but for now, it’s Landscape.

So, in version 1.2.0, where I include a UINavigation Controller, my app went all wonky.  Multiplayer loaded Portrait, and that did not look good at all.  So, what did I do?  First thing off, in the Multiplayer

- (void)viewDidLoad

I put the line:

[self.navigationController setNavigationBarHidden:YES];

That got rid of the Navigation bar, which was taking up too much room.  But then, instead of using “Push” with the UINavigation Controller, I fell back to some old code to get the new view onto the screen.  One that, you know, respected my orientation preferences.

MultiPlayerViewController *controller = [[MultiPlayerViewController alloc] initWithNibName:@”MultiPlayerView” bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];

Basically, this makes the controller, assigns the delegate back to the view that calls it (which you then use to get rid of the Multiplayer view, as shown in the Utility app), makes the transition, and then shows it.  This causes the Multiplayer view to be loaded in a different way, one that actually correctly orients it.  So now the rest of the app lives with the UINavigation Controller, while Multiplayer is free!  It’s wonderful!

Return top

A Little about me...

I am a college programmer, going to Rochester Institute of Technology. Instead of spending my summers working in a gas station, I have taken it upon myself to start my own business which I will continue to manage throughout my college years.