【发布时间】:2009-12-07 15:59:39
【问题描述】:
在 iphone 应用程序中,我们可以设置 UIAlertView 中的列数,就好像我在 UIAlertView 中有六个按钮,那么我如何在 2 列和 3 行中显示它。如果有人做过,请分享它是如何做的..
任何示例代码都将是额外的帮助
【问题讨论】:
标签: iphone button uialertview
在 iphone 应用程序中,我们可以设置 UIAlertView 中的列数,就好像我在 UIAlertView 中有六个按钮,那么我如何在 2 列和 3 行中显示它。如果有人做过,请分享它是如何做的..
任何示例代码都将是额外的帮助
【问题讨论】:
标签: iphone button uialertview
UIAlertView 只是 UIView。因此,您可以在两列配置中手动将按钮添加到UIAlertView。有一个示例 here 演示了添加 UITextFields,但我相信你可以适应它。
请注意,UIAlertView 中有两个许多按钮可能会支持 Apple ;-)
【讨论】:
我是这样做的
NSArray *subViewArray = Topicdialog.subviews;
float y = 60.0f;
for(int x=2;x<[subViewArray count];x += 2){
UIView *button = [subViewArray objectAtIndex:x];
CGRect frame = button.frame;
frame.size.width = 120.0f;
frame.size.height = 42.0f;
frame.origin.x = 20.0f;
frame.origin.y = y;
button.frame = frame;
UIView *button1 = [subViewArray objectAtIndex:x + 1];
frame = button1.frame;
frame.size.width = 120.0f;
frame.size.height = 42.0f;
frame.origin.x = 152.0f;
frame.origin.y = y;
button1.frame = frame;
y = y + 48.0f;
}
【讨论】: