自定义 UIAlertView

发布于 2024-07-13 07:15:23 字数 391 浏览 4 评论 0原文

任何人都有代码可以做到这一点:

UIAlertViewHack
(来源:booleanmagic.com

或更好,3x2使用 UIAlertView 对象的带有图像的按钮网格?

我不关心文本字段,它是我想要的网格中的按钮(最好是图像而不是文本)。

Anyone have code to make this:

UIAlertViewHack
(source: booleanmagic.com)

or better yet, a 3x2 grid of buttons with images using the UIAlertView object?

I don't care about the textfield, it's the buttons in a grid I want (preferably with images rather than text).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

心欲静而疯不止 2024-07-20 07:15:23

我认为你最好的选择是忘记自定义 UIAlert 视图并自己构建自定义视图。

其一,您所显示的实际上不是“警报”,因此它与 UIAlertView 的设计目的背道而驰。 这意味着您正在更改用户的 UI 范例,这绝不是一个好主意。

其次,将自定义视图设置为动画比尝试破解 UIAlertView 以使其执行您想要的操作要容易得多。

I think your best bet is to forget customizing UIAlert view and build a custom view yourself.

For one, what you're showing really isn't an "alert" so it's counter to what UIAlertView is designed to be for. This means that you're changing the UI paradigm on the user which is never a good idea.

Second, it would be much easier to animate a custom view into place than to try and hack UIAlertView to get it to do what you want.

悟红尘 2024-07-20 07:15:23

首先,您需要使警报框更大以容纳您的控件,但它必须放置在中心。

为此,不要设置帧大小,而是将消息文本中的“\n”作为 necc。 例如:

alert = [[UIAlertView alloc] initWithTitle:@"Rate this picture."
message:@"Tap a star to rate.\n\n\n\n " /*------ look at here!!----*/
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];

然后使用 UIAlertViewDelegate 作为警报视图。

覆盖它的 viewWillAppear:
添加按钮并手动将其框架设置在所需位置。

或者:
使用视图控制器创建一个完整的视图,并将视图添加到警报框中,例如:

[myalertview addSubvew:mycomplexalert];

希望这会对您有所帮助:)

我正在使用警报框对带有明星图像、twitter、fb 反馈等的输入进行评级。

更新 iOS7:

对于iOS 7,使用组件创建您自己的视图并将其设置为警报视图的附件视图:

[alert setValue:imageView forKey:@"accessoryView"]; 

这很简单:-)

First you need to make the alert box bigger to accomodate your controls, yet it has to be placed at the center.

For this, instead of setting the frame size, your the message text with "\n"s as necc. e.g.:

alert = [[UIAlertView alloc] initWithTitle:@"Rate this picture."
message:@"Tap a star to rate.\n\n\n\n " /*------ look at here!!----*/
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];

Then use a UIAlertViewDelegate for the alertview.

override its, viewWillAppear:
add your buttons and set their frames manually at desired position.

OR:
create a entire view with a view controller, and add the view to the alert box like:

[myalertview addSubvew:mycomplexalert];

Hope this will come into your help :)

I am using alert boxes for rating input with star images,twitter,fb feedback etc.

UPDATE iOS7:

For iOS 7, create your own view with components and set it as the alertview's accessory view:

[alert setValue:imageView forKey:@"accessoryView"]; 

Its thats simple :-)

安稳善良 2024-07-20 07:15:23

本教程介绍了如何子类化 UIAlertView 来实现输入文本框。 它解释了如何放大视图、添加子视图(如文本框或图像)以及进行转换以将框移到屏幕上更高的位置。

This tutorial covers how to subclass UIAlertView to achieve an input text box. It explains how to enlargen the view, add subviews (like text boxes or images) and make a transform to move the box up higher on the screen.

旧人哭 2024-07-20 07:15:23

我编写了一个几乎像素完美的 UIAlertView 替代品,它也是完全可配置的。 如果CODialog 适合您的需求,请查看它。

I wrote a almost pixel perfect UIAlertView replacement, that's also fully configurable. Have a look at CODialog if it fits your needs.

℉服软 2024-07-20 07:15:23

没有用于此目的的内置组件。 根据 HIG 文档,UIAlertView 应该只有文本和按钮。

您必须创建自己的视图并向其添加控件。 SDK 中的 HeadsUpUI 示例展示了如何将自定义的类似菜单的视图显示为叠加层。

希望有帮助。

There are no in-built components for this. UIAlertView should just have text and buttons as per the HIG document.

You will have to create your own view and add controls to it. The HeadsUpUI example in the SDK shows how to show a custom menu-like view as an overlay.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文