3

I am trying to display a login screen using presentModalViewController on iPad.

LoginFormController *controller = [[[LoginFormController alloc] initWithNibName:@"LoginFormView" bundle:nil] autorelease];
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[controller setModalPresentationStyle:UIModalPresentationFormSheet];
[self controller:loginFormController animated:YES];

No matter what size I set the view to be in Interface Builder, it always resizes to about 540x620. But the login screen is nothing more than two text fields and a button. So I only need it to be 460x240.

Does anybody know of a way to resize this?

Tom van Zummeren
  • 9,130
  • 12
  • 52
  • 63
  • Not sure why the response is that it can't be done or that you should use an alert. A perfectly working answer has been provided here: http://stackoverflow.com/questions/2457947/how-to-resize-a-uipresentationformsheet/4271364#4271364 – StudentJ Jan 30 '12 at 03:45

1 Answers1

7

Try reading the iPad HIG section on Modal Views. Its pretty clear why that won't work. No body can really tell you much when not in Apple's dev forms since we are under NDA. However the solution I would use if I were you isn't iPad specific but rather what quite a few iPhone apps have been doing for a while. Use a UIAlert view and put your two text fields in that? The down side is you can't use IB to lay it out. Tutorial

jamone
  • 17,253
  • 17
  • 63
  • 98
  • Yeah I read it too, and I thought logging in was something you would use a modal state for. But what you're proposing is ALSO something that goes against the human interface guidelines, because then I misuse an alert dialog. Maybe I'll use a popover view for logging in instead. – Tom van Zummeren Feb 11 '10 at 19:39
  • I'm not saying that what you are trying to do goes against the HIG I'm just saying the HIG explains why what you are trying isn't working. I've heard the misuse an alert dialog comment before, however tons of apps are getting approved using the alert view this way. Even Apple uses it this way. If you log out of you iTunes account on an iPod touch/iPhone then try to purchase something it pops up a UIAlertView with username & password text boxes. A popover may work in your case but since the user can dismiss a popover it may not work since not logging in what is there to do in the app? – jamone Feb 11 '10 at 19:46
  • I was never worried about whether or not it would be approved by Apple. I was just concerned about the user experience. People don't "expect" text input boxes in an alert popup. That's why it's good to follow the guide lines. But you're right, Apple also does it in the appstore. But a popover might work, since you can still do other stuff when not logged in. Anyway, I think you gave the correct answer after all: you simply can't adjust the size of a modal view. =) – Tom van Zummeren Feb 11 '10 at 21:19