有谁知道自定义 UIAlertView 类在 iOS5 中的工作原理吗? 我正在寻找像 TSAlertView 这样的类,这样我就可以将 2 个堆叠的按钮置于警报状态。 ( http://cocoacontrols.com/platforms/ios/controls/tsalertview )
感谢您的帮助。
最佳答案
iOS 5
中的UIAlertView
具有UIAlertViewStyles
UIAlertViewStyleDefault
UIAlertViewStyleSecureTextInput
UIAlertViewStylePlainTextInput
UIAlertViewStyleLoginAndPasswordInput
编辑 很抱歉误解了您的问题。链接页面中显示的警报 View 非常容易重现。这是我想出的:
为了方便起见,我用一个类别来实现它,但您可以轻松地在其他地方实现它。基本上你所做的是添加一个取消按钮然后隐藏它。这样一来,就警报 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/