gpt4 book ai didi

ios - 当应用程序进入后台进程到 ios 中的事件进程时,我将显示可编辑的警报 View

转载 作者:行者123 更新时间:2023-11-28 21:31:22 27 4
gpt4 key购买 nike

hii friend 我将创建密码类型 alertview。当应用程序进入后台激活模式时密码 alertview 显示。然后我将最小化第二次应用程序比我打开应用程序两次显示 alertview 到app.like 上次背景 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;
}
}

请解决我的问题 friend 。感谢提前

最佳答案

简单地将此行添加到您创建警报 View 的 Appdelegate.m 文件下方。

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

关于ios - 当应用程序进入后台进程到 ios 中的事件进程时,我将显示可编辑的警报 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35931959/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com