如何在 iOS 中全屏显示 UIAlertView?
How can I display an UIAlertView as full screen in iOS?
如何在 iOS 中全屏显示 UIAlertView?
有时会弹出 tableview,这是一个非常大的问题。所以使用 alertview 显示 tableview 很容易,但不会扩展大小。为此,如何在 iOs 中全屏显示警报视图?
你不能change/alter苹果默认UIAlertView。
而是使用自定义视图并模仿它的行为,您可能想要添加 YourCustomAlertView
来喜欢:
CustomAlert.h
@interface CustomAlert : NSObject
+ (void)alertShow;
+ (void)alertHide;
@end
CustomAlert.m
@implementation CustomAlert
+ (void)alertShow
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIView *existingView = [window viewWithTag:123456789];
if (existingView != nil ) // removes existing alert view to avoid multi occurance
{
[existingView removeFromSuperview];
}
UIView *YourCustomAlertView = [[UIView alloc] initWithFrame:YourFrame];
YourCustomAlertView.tag = 123456789; // add tag to remove the view later
// ...
[window addSubview: YourCustomAlertView];
//this will place your `YourCustomAlertView` to the top most like the default UIAlertView...
[UIView animateWithDuration:0.3 animations:^{ [YourCustomAlertView setAlpha:1]; }];
}
+ (void)alertHide
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIView * YourCustomAlertView = [window viewWithTag: 123456789];
[UIView animateWithDuration:0.3 animations:^{
[YourCustomAlertView setAlpha:0];
} completion:^(BOOL done){ if (done) { [YourCustomAlertView removeFromSuperview]; } }];
}
@end
像这样使用它:
[CustomAlert alertShow];
注意: 这只是制作 CustomUIAlertView
的指南,或者如果您不想自己搜索一些现成的 CustomAlertView
,抱歉我不使用任何所以我不能推荐..
这只是一个示例,您可以随意更改任何内容,也许您想添加 initWithTitle: message: button:
由您决定。以及许多其他细节...
干杯! :)
Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons. You must set a delegate if you add custom buttons. The delegate should conform to the UIAlertViewDelegate protocol. Use the show method to display an alert view once it is configured.
所以没办法修改UIALertView
。您需要创建自己的 AlertView
.
只需创建一个视图并在需要显示警报时使其可见。 github like this . Also you can find on Cocoapods 示例中也有示例。
如何在 iOS 中全屏显示 UIAlertView? 有时会弹出 tableview,这是一个非常大的问题。所以使用 alertview 显示 tableview 很容易,但不会扩展大小。为此,如何在 iOs 中全屏显示警报视图?
你不能change/alter苹果默认UIAlertView。
而是使用自定义视图并模仿它的行为,您可能想要添加 YourCustomAlertView
来喜欢:
CustomAlert.h
@interface CustomAlert : NSObject
+ (void)alertShow;
+ (void)alertHide;
@end
CustomAlert.m
@implementation CustomAlert
+ (void)alertShow
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIView *existingView = [window viewWithTag:123456789];
if (existingView != nil ) // removes existing alert view to avoid multi occurance
{
[existingView removeFromSuperview];
}
UIView *YourCustomAlertView = [[UIView alloc] initWithFrame:YourFrame];
YourCustomAlertView.tag = 123456789; // add tag to remove the view later
// ...
[window addSubview: YourCustomAlertView];
//this will place your `YourCustomAlertView` to the top most like the default UIAlertView...
[UIView animateWithDuration:0.3 animations:^{ [YourCustomAlertView setAlpha:1]; }];
}
+ (void)alertHide
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIView * YourCustomAlertView = [window viewWithTag: 123456789];
[UIView animateWithDuration:0.3 animations:^{
[YourCustomAlertView setAlpha:0];
} completion:^(BOOL done){ if (done) { [YourCustomAlertView removeFromSuperview]; } }];
}
@end
像这样使用它:
[CustomAlert alertShow];
注意: 这只是制作 CustomUIAlertView
的指南,或者如果您不想自己搜索一些现成的 CustomAlertView
,抱歉我不使用任何所以我不能推荐..
这只是一个示例,您可以随意更改任何内容,也许您想添加 initWithTitle: message: button:
由您决定。以及许多其他细节...
干杯! :)
Use the properties and methods defined in this class to set the title, message, and delegate of an alert view and configure the buttons. You must set a delegate if you add custom buttons. The delegate should conform to the UIAlertViewDelegate protocol. Use the show method to display an alert view once it is configured.
所以没办法修改UIALertView
。您需要创建自己的 AlertView
.
只需创建一个视图并在需要显示警报时使其可见。 github like this . Also you can find on Cocoapods 示例中也有示例。