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

时间:2011-06-07 07:00:49

标签: iphone objective-c

我很困惑。如何在使用应用程序时只显示一次协议页面。我不知道如何解释这一点。但我想解释一下。 我正在创建应用程序,其中我有协议页面,其中包含两个按钮 (1)按钮名称为Accept (2)按钮名称为拒绝

如果用户单击“接受”按钮应用程序,请进入下一页但是当用户单击“拒绝”按钮时,应用程序退出应用程序。 但扭曲就在这里 如果用户第一次运行此应用程序,他会看到协议页面,如果用户接受此协议,那么只有在他移动得更远之后。但是当用户一次又一次地使用此应用程序时,如果他一次又一次地看不到协议页面已经接受了协议。 请帮帮我,我怎么能解决这个问题我很困惑。 提前谢谢

2 个答案:

答案 0 :(得分:4)

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

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

enter image description here

代码不显示协议如果被接受一次

将一个plist文件添加到资源文件夹中   在plist 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]; 

   }

答案 1 :(得分:3)

最佳解决方案是在您将应用程序发送到iTunes Connect时签署此许可协议,它有一个特别适合的地方。

因此,如果用户不同意,他将不会首先安装该应用

检查“iTunesConnect DeveloperGuide”第52页的“EULA”部分

希望它对你有所帮助。