选择页面(许可协议页面)时出现问题 [英] Problem with opning the page (License agreement page)

查看:50
本文介绍了选择页面(许可协议页面)时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑.如何在使用应用程序时仅显示一次协议页面.我不怎么解释.但是我正在尝试解释这一点.我正在创建应用程序,其中我有带有两个按钮的协议页面(1)按钮名称为接受"(2)按钮名称为拒绝

I am very confused. How can display agreement page only once in time of use of application.I don't how can i explain this .But I am trying to explain this . I am creating the application in which i have the agreement page which has the two button (1)Button name is Accept (2)Button name is Reject

如果用户单击接受"按钮应用程序,则进入下一页;但是,当用户单击拒绝"按钮应用程序时,该应用程序退出.但是转折就在这里如果用户第一次运行此应用程序,则他会看到协议页面,而如果用户接受此协议,则只有在他走得更远之后才可以.但是,当用户一次又一次使用此应用程序时,如果他再次访问该协议页面,则他不能再一次看到协议页面.已经接受该协议.请帮我解决这个问题,我很困惑.预先感谢

If user click the Accept button application enter into the next page But when the user click on the Reject button application exit out from the application . But the twist is here If user run this application first time he see the agreement page and if user accept this agreement then only then after he move farther .But when user use this application again and again he must not see the agreement page again and again if he already accept the agreement. Please help me out how can i solve this I am very confused. thanks in advance

推荐答案

您可以通过更改视图"应用协议页面

YOU CAN Apply the Agreement Page through The Alter View

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

If User Accept the Agreement than You Store The Value of Agreed(Possibly Bollean) in the plist file(possibly from document directory of the app) than each time you can check it

不显示代码以显示协议是否接受一次

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

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

add one plist file in to resource folder
Add one boolean variable in plist Set Value AS UNCHECKED(REJECTED STATE)

///将plist复制到文档目录

//Copy the plist to document directory

-(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]; 

   }

这篇关于选择页面(许可协议页面)时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆