开发者

How to display a simple popup for user input on iPad

开发者 https://www.devze.com 2023-01-24 10:37 出处:网络
How do I display a simple popup for text entry on iPad.I want a small popup to display in the middle of the screen with one line for text entry and two buttons.A UIPopover doesn\'t seem appropriate as

How do I display a simple popup for text entry on iPad. I want a small popup to display in the middle of the screen with one line for text entry and two buttons. A UIPopover doesn't seem appropriate as there 开发者_如何学Gois nothing the popover would point to. UIActionSheets don't allow for text entry. A Modal view is too large when it displays. Is there another option?

This must be very simple. What am I missing? I'm not looking for an exhaustive response. Just point me in the right direction.


It's a great question that I lose sleep over.

I have come to believe a UIPopover is in fact best.

Exactly as you say in some cases "there is nothing the popover would point to"...sometimes that is the problem.

I believe if you push a bit, there is usually SOMETHING that it makes just a little sense for it to point to. After all, it must relate to something the user has pushed (come from that point) or to some aspect of computers (if it's got something to do with networking or a user account, come off a networking icon or button).

In one case we made a small relevant icon appear, for the sole reason that the popover had something to point to!

You probably agree that everything about the popover, is absolutely perfect for the job. The only issue is that sometimes it feels like "where should it emit from?"

I feel the correct solution is just to think harder to find SOMETHING that is reasonable for it to emit from. I mean it could be just the logo of the app, or surely one of your buttons on screen. As long as it makes even just a little sense, the user will interpret it with no problems. (FWIW IMO your mind does not much process the arrow-thing on popovers ... it's very ancillary.)

IMO that is the best answer. You have to workaround the annoying "sometimes not much emission point for the popover" because once you do go to a popover, everything is absolutely perfect and wonderful, like in a heaven.

It is a great question. The fact is Apple should add a "pointless popover" for just this situation!

An immediate solution to let you get on with it is make a small relevant icon appear for the sole purpose of giving the popover something to point to!


I know, this thread is really old. But I needed this kind of solution now and found something:

[popover presentPopoverFromRect:[self view].frame inView:[self view] permittedArrowDirections:0 animated:YES];

The zero disables the little arrow and [self view].frame gets the middle of the screen. One thing I didn't find an answer for now is that the right top corner of the UIPopup is centered on screen, not the whole popover itself.


Just found a solution! This works great for me (in landscape):

CGRect center = CGRectMake(([self view].frame.size.width/2), ([self view].frame.size.height/4), 290, 290);
[popover presentPopoverFromRect:center inView:[self view] permittedArrowDirections:0 animated:YES];

Is think for portrait mode you'll have to exchange the dividations. So it might be ([self view].frame.size.width/4), ([self view].frame.size.height/2) but I'm not sure.

0

精彩评论

暂无评论...
验证码 换一张
取 消