当应用程序在 ios 中进入后台进程到活动进程时,我将显示可编辑的警报视图
i will display editable alertview when aplication is going to background process to active process in ios
hii 朋友我将创建密码类型 alertview.when 应用程序进入后台激活模式那个时候密码 alertview display.than 在我将第二次应用程序最小化之后比在我打开应用程序之后比时间两次在 app.like 上次显示背景警报视图和当前 alertview.but 中显示警报视图,我随时只想要一个警报视图。
这是我的代码
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;
}
}
请解决我的问题friends.thanks提前
当您第二次打开应用程序时,循环遍历所有子视图,当您找到以下匹配项时:
isKindOfClass:[UIAlertView class]]
从父视图中删除该视图,并再次显示警报。
简单地将此行添加到创建警报视图的 Appdelegate.m 文件下方。
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification){
[message dismissWithClickedButtonIndex:0 animated:NO];
}];
hii 朋友我将创建密码类型 alertview.when 应用程序进入后台激活模式那个时候密码 alertview display.than 在我将第二次应用程序最小化之后比在我打开应用程序之后比时间两次在 app.like 上次显示背景警报视图和当前 alertview.but 中显示警报视图,我随时只想要一个警报视图。 这是我的代码 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;
}
}
请解决我的问题friends.thanks提前
当您第二次打开应用程序时,循环遍历所有子视图,当您找到以下匹配项时:
isKindOfClass:[UIAlertView class]]
从父视图中删除该视图,并再次显示警报。
简单地将此行添加到创建警报视图的 Appdelegate.m 文件下方。
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification* notification){
[message dismissWithClickedButtonIndex:0 animated:NO];
}];