Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当应用程序在ios中将后台进程转换为活动进程时,我将显示可编辑的alertview_Ios_Uialertview - Fatal编程技术网

当应用程序在ios中将后台进程转换为活动进程时,我将显示可编辑的alertview

当应用程序在ios中将后台进程转换为活动进程时,我将显示可编辑的alertview,ios,uialertview,Ios,Uialertview,hii friends我将创建密码类型alertview。当应用程序进入后台活动模式时,密码alertview显示。之后我将最小化第二次应用程序,之后我将打开应用程序,然后在应用程序中显示两次alertview。就像上次后台alertview和当前alertview。但我只想要一次随时查看。 这是我的密码 Appdelegate.m - (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(

hii friends我将创建密码类型alertview。当应用程序进入后台活动模式时,密码alertview显示。之后我将最小化第二次应用程序,之后我将打开应用程序,然后在应用程序中显示两次alertview。就像上次后台alertview和当前alertview。但我只想要一次随时查看。 这是我的密码 Appdelegate.m

 - (void)applicationDidEnterBackground:(UIApplication *)application {


    NSLog(@"applicationDidEnterBackground");
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Enter Password?"
                                                      message:nil
                                                     delegate:self
                                            cancelButtonTitle:nil
                                            otherButtonTitles:@"Continue", nil];

    [message setAlertViewStyle:UIAlertViewStyleSecureTextInput];
    UITextField *textField = [message textFieldAtIndex:0];
    assert(textField);
    textField.keyboardType = UIKeyboardTypeNumberPad;
    [message show];

       // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {




}

- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *password = [defaults objectForKey:@"name"];

    NSString *inputText = [[alertView textFieldAtIndex:0] text];
    if( [inputText isEqualToString:password] )
    {
        return YES;
    }
    else
    {
        return NO;
    }
}

请解决我的问题,朋友们。感谢您的帮助。当您第二次打开应用程序时,请循环浏览所有子视图,并在找到以下内容的匹配项时:

    isKindOfClass:[UIAlertView class]]

从superview中删除该视图,然后再次显示警报。

当您第二次打开应用程序时,循环浏览所有子视图,并在找到以下内容的匹配项时:

    isKindOfClass:[UIAlertView class]]

从superview中删除该视图,然后再次显示警报。

简单地在创建警报视图的Appdelegate.m文件下面添加这一行

   [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification){
        [message dismissWithClickedButtonIndex:0 animated:NO];
    }];

简单地在创建alertview的Appdelegate.m文件下面添加这一行

   [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification){
        [message dismissWithClickedButtonIndex:0 animated:NO];
    }];

不推荐使用UIAlertView。不推荐使用UIAlertController.UIAlertView。使用UIAlertController.pls解释详细信息浏览当您要删除以前的alertview时,请扫描当时存在的所有子视图,当您找到属于uialertclass类的子视图时,请从superview中删除该子视图。请解释详细信息浏览当您要删除以前的alertview时,扫描此时存在的所有子视图,当您找到属于uialertclass类的子视图时,从superview中删除该子视图。