iOS5中的自定义UIalertView [英] Custom UIalertView in iOS5

查看:139
本文介绍了iOS5中的自定义UIalertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

知道自定义UIAlertView类在iOS5中有什么用吗?
我正在寻找像TSAlertView这样的课程,我可以将2个按钮叠加到警报状态。
http://cocoacontrols.com/platforms/ios/controls/tsalertview

Do anywho know a custom UIAlertView class what is working in iOS5 ? I'm looking for a class like TSAlertView, with that I will able to put 2 buttons stacked into alert. ( http://cocoacontrols.com/platforms/ios/controls/tsalertview )

Thanx寻求帮助。

Thanx for help.

推荐答案

UIAlertView in iOS 5 UIAlertViewStyles

UIAlertViewStyleDefault
UIAlertViewStyleSecureTextInput
UIAlertViewStylePlainTextInput
UIAlertViewStyleLoginAndPasswordInput

编辑很抱歉误解了您的问题。链接页面中显示的警报视图非常容易重现。以下是我提出的建议:

EDIT Sorry for misunderstanding your problem. The alert view shown in the linked page is extremely easy to reproduce. Here's what I came up with:

为方便起见,我用类别实现了这一点,但您可以轻松地在其他地方实现它。基本上你要做的是添加一个取消按钮,然后隐藏它。这样,就警报视图而言,有三个按钮,它不会并排放置两个可见按钮。类别实现如下:

I implemented this with a category for convenience but you could easily just implement it elsewhere. Basically what you do is add a cancel button and then hide it. That way there are three buttons as far as the alert view is concerned and it does not place the two visible buttons side by side. The category implementation is as follows:

-(void)showWithCutCancelButton{
    // Make sure alert view will look right
    if (self.cancelButtonIndex == -1 || self.numberOfButtons < 3) return;
    self.clipsToBounds = YES; // or else cancel button will still be visible
    [self show];
    // Shrink height to leave cancel button outside
    self.bounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height - 64);
} 

然后通过致电显示:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello" message:@"Message here" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Option1", @"Option2", nil];
[alert showWithCutCancelButton];

这篇关于iOS5中的自定义UIalertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆