[英]How can I force UIAlertView to display the full message without scrolling when in landscape mode?
[英]How can I display an UIAlertView as full screen in iOS?
如何在iOS中將UIAlertView顯示為全屏? 有時候彈出tableview是一個很大的問題。 因此,使用alertview顯示tableview很容易,但不能擴展大小。 為此,如何在iO中全屏顯示alertview?
您不能更改/更改蘋果的默認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:
由您自己決定。 和許多其他細節...
干杯! :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.