iphone - 如何使用 UIAlertView 生成多行而不是单行?

标签 iphone objective-c ios4 uialertview

这是我的代码

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Added to Cart" message:@"Some items are added for time being!" delegate:self cancelButtonTitle:@"View Cart" otherButtonTitles:@"Continue \n Shopping", nil];
alert.tag = 20;
[alert show];

我得到这样的输出:
enter image description here

我需要这样的:
enter image description here

最佳答案

我为您提供了手动解决方案。但我认为这不是一个好的解决方案:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Added to Cart" message:@"Some items are added for time being!" delegate:self cancelButtonTitle:@"View Cart" otherButtonTitles:@"", nil];

    UILabel *buttonTitle = [[UILabel alloc] initWithFrame:CGRectMake(148, 102, 125, 40)];
    buttonTitle.text = @"Continue Shopping";
    buttonTitle.font = [UIFont boldSystemFontOfSize:15];
    buttonTitle.textColor = [UIColor whiteColor];
    buttonTitle.textAlignment = UITextAlignmentCenter;
    buttonTitle.backgroundColor = [UIColor clearColor];
    buttonTitle.numberOfLines = 2;
    [alert addSubview:buttonTitle];
    alert.tag = 20;
    [buttonTitle release];
    [alert show];

无论如何你都可以使用它......

关于iphone - 如何使用 UIAlertView 生成多行而不是单行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10735703/

相关文章:

objective-c - 允许与另一个 UIView 下的 UIView 交互

iphone - 捕获UIView中的所有触摸事件?

ios - 通过程序开发多个图表

ios4 - 有什么方法可以在 Objective-C/iPhone/iOS SDK 中禁用 CALayer 的 rasterizationScale 插值/抗锯齿功能吗?

iphone - CGRect 在动画期间不改变

objective-c - < > 在类接口(interface)中意味着/代表什么?

iPhone - UIScrollView ...检测触摸坐标

objective-c - Uncrustify:删除 ObjC 代码中的双及更多空行

iphone - iOS 将核心数据保存到服务器/云端

ios - PHAsset图像是否在所有iPhone上都具有全局唯一性?