【问题标题】:how to resize alertview in iphone如何在iphone中调整alertview的大小
【发布时间】:2011-11-14 09:40:28
【问题描述】:

嗨,我想在大字体上显示我的 alertview 消息,以便用户在我运行时可以正确阅读,但它只向我显示如何根据 ipad 重新调整消息的字体我尝试这个,但它对我不起作用我的代码帮助我解决这个问题

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    UIAlertView* alert=[[UIAlertView alloc] initWithTitle:@"Flight Search" message:@"Please select both outbound and inbound flights" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    //UIAlertView* alert = [[[UIAlertView alloc] init]initWithFrame:CGRectMake(100,0,340,200)];// message:@"Please select both outbound and inbound flights" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    //[alert setTitle:@"Flight Search"];
    //[alert setCenter:CGPointMake(160.0f, 240.0f)];
    //alert.frame = CGRectMake( 100, 0, 600, 500 );
    //[alert setNeedsLayout];

    [alert show];
    alert.frame = CGRectMake( 0, 0, 340, 200 );
    //alert.frame = CGRectMake( 100, 0, 600, 250 );
    [alert release];
}
else {
    UIAlertView* alert=[[UIAlertView alloc] initWithTitle:@"Flight Search" message:@"Please select both outbound and inbound flights" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
}

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    来自UIAlertView 文档:

    UIAlertView 类旨在按原样使用,而不是 支持子类化。此类的视图层次结构是私有的,并且 不得修改。

    你不能修改它。

    查看此question/response 了解如何制作自定义警报视图:

    【讨论】:

      【解决方案2】:

      默认的 UIALertView 不能根据 Apple 的文档进行修改,而是制作自己的自定义 AlertView

      【讨论】:

        【解决方案3】:

        UIAlertView 内部有 UITextView,带有两个或单个按钮。这就是为什么它可以根据输入垂直而不是水平扩展的原因。如果您需要扩展它,增加消息内容但您无法更改字体大小。

        【讨论】:

        • 如果我在消息字段中输入的消息跨越 2 行,警报视图应该自动调整其垂直大小吗?不知何故,我的只是在文本框下显示文本。帮忙?
        【解决方案4】:

        您可以使用默认警报视图做任何事情。它将根据您编写的文本重新调整大小。如果您愿意,那么您需要创建自己的自定义警报视图。 Check the link。放置自定义图像和按钮,然后您就可以重新调整大小。

        【讨论】:

          猜你喜欢
          • 2011-11-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-09-13
          • 2012-02-22
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多