Porting my app Biblicious from iOS to OS X, Part 3

Biblicious for Mac has been slow going. I’ve had some time to devote to it recently, and it has been frustrating.

On the plus side, I was able to fix the bug where the game would start, play for about one second and tell you that your time was up. I suppose I could have left that bug in there, called it a feature, and changed the name to Biblicious Masters Edition. 😀

The main problem I am having right now is finding a good replacement for UIAlertView on iOS. NSAlert just won’t cut it. I need a view that will display & then close after a defined amount of time. Some people use NSAlert and have the default button automatically “click” but then the user has to see the button. Ugly.

I decided to create my own view. I opened interface builder & in the same xib as the game view added my new “dialogView”, designed with a label for a title, a label for the message, and two buttons.  I also added a test button on the game screen next to the “Escape” button called “Test”. In Test’s action, I instantiated my view & added it as a subView. Good. Run the project, start a game, click “Test” and nothing. The game keeps playing as normal. I decide to try showing the view as a sheet on the window. A sheet rect looked like it was displaying but I saw nothing.

My next step was to create a new window in the xib & toss the view in there. I did that and when “Test” was clicked, tiny square came down as a sheet. I went back and init’d the window with a Rect and this time I had a blank sheet of the correct proportions! After a few iterations I removed the view from the new window & placed all of the controls from the view directly on the window. This time when the sheet displayed, it was transparent but still no controls were visible.

I switched back to the view method and here we are. If you have any suggestions for displaying a “modal” view on top of another view, I’d love to hear it. Here is the code as it stands now:

– (IBAction)testButtonPushed:(id)sender {

    _dialogView = [[NSViewalloc] initWithFrame:NSMakeRect(0, 0, 712, 416)];

    [self.viewaddSubview:_dialogViewpositioned:NSWindowAboverelativeTo:self.view];

}