iphone - iOS5 中的自定义 UIalertView

标签 iphone ios ios5

有谁知道自定义 UIAlertView 类在 iOS5 中的工作原理吗? 我正在寻找像 TSAlertView 这样的类,这样我就可以将 2 个堆叠的按钮置于警报状态。 ( http://cocoacontrols.com/platforms/ios/controls/tsalertview )

感谢您的帮助。

最佳答案

iOS 5 中的UIAlertView 具有UIAlertViewStyles

UIAlertViewStyleDefault
UIAlertViewStyleSecureTextInput
UIAlertViewStylePlainTextInput
UIAlertViewStyleLoginAndPasswordInput

编辑 很抱歉误解了您的问题。链接页面中显示的警报 View 非常容易重现。这是我想出的:

enter image description here

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

-(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];

关于iphone - iOS5 中的自定义 UIalertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8272065/

相关文章:

iphone - 如何复制 Mail.app 的垃圾动画

iphone - 如何更改 xcode 中的 subversion 设置?

ios - 通过键盘应用程序或 iMessage 应用程序截取屏幕截图

ios - #import 在 Xcode(版本 6.3)中找不到 .h 文件

objective-c - 检查 NSEntityDescription 键是否存在

ios - 使用另一个 UINavigationController 推送 View Controller

facebook - 包括已弃用的 Facebook header 文件夹会出错

iphone - IOS项目中的C++前向引用(前向引用 'enum'类型)

ios - 如何在具有索引行单元格的同一 View Controller 中加载两个 TableView ?

ios - Xcode 7.2.1 Swift 2.1.1 无法将类型 'Dictionary<_,_>' 的值分配给类型 'Dictionary'