アプリケーションがバックグラウンドプロセスからiOSのアクティブプロセスに移行するときに、編集可能なアラートビューを表示します

ジガー

hii friends私はパスワードタイプalertviewを作成します。アプリケーションがバックグラウンドでアクティブモードになると、その時間はパスワードalertviewが表示されます。前回のバックグラウンドalertviewと現在のalertviewのようですが、いつでも1つの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;
    }
}

私の問題の友達を解決してください。事前に感謝します

ジガー

アラートビューを作成するAppdelegate.mファイルの下にこの行を追加するだけです。

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

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ