gpt4 book ai didi

iphone - 打开页面时出现问题(许可协议(protocol)页面)

转载 作者:太空狗 更新时间:2023-10-30 04:01:27 26 4
gpt4 key购买 nike

我很困惑。如何在使用应用程序时只显示一次协议(protocol)页面。我不知道我该如何解释。但我正在尝试解释这一点。我正在创建应用程序,其中我有带有两个按钮的协议(protocol)页面(1)按钮名称为Accept(2)按钮名称为Reject

如果用户点击接受按钮应用程序进入下一页但是当用户点击拒绝按钮应用程序退出应用程序。但转折就在这里如果用户第一次运行此应用程序,他会看到协议(protocol)页面,如果用户接受此协议(protocol),则只有在他走得更远后才会看到。但是,当用户一次又一次地使用此应用程序时,他不能一次又一次地看到协议(protocol)页面,如果他已经接受协议(protocol)。请帮我解决这个问题,我很困惑。提前致谢

最佳答案

您可以通过 Alter View 应用协议(protocol)页面

如果用户接受协议(protocol),那么您将同意的值(可能是 Bollean)存储在 plist 文件中(可能来自应用程序的文档目录) 比每次都可以检查

enter image description here

CODE FOR TO NOT TO Display Agreement If it is accepted For once

在资源文件夹中添加一个plist文件
在 plist 中添加一个 bool 变量 Set Value AS UNCHECKED(REJECTED STATE)

//复制plist到文档目录

-(void)CopyPlistTODocument
{

BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}

}

//NOW Call Another method that read data form plist of document directory
-(void)desclaimer
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"setting.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
BOOL *temp=[plist valueForKey:@"Agreement"];
//if the value of the temp got YES That Agreed earlier so no need to agreed again
if ([temp isEqualToString:@"NO"])
{
//Show Alert View From Here And call Method Accept() on the button pressed event of the accept button
}
}
//Now From Button Pressed Event Of The Accept Here is the Accept method
-(void)Accept
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"Settings.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
[plist setValue:@"YES" forKey:@"Agreement"];
//now every time the value read from here has agreed state so alert view will not get called
[plist writeToFile:path atomically:YES];

}

关于iphone - 打开页面时出现问题(许可协议(protocol)页面),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6261655/

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