你可以通过ALTER VIEW应用协议页
和
如果用户接受比你存储的约定的价值(可能Bollean)在plist文件(可能的文档目录的协议APP) 每次比你可以检查它
CODE FOR如果接受一次
TO不显示协议
中添加一个plist文件到资源文件夹
添加一个布尔变量的plist值作为取消选中(遭到拒绝的州)
//复制的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];
}
我怎么能做到这一点,你能解释我更多 – Ajay 2011-06-07 08:45:50
检查更新的代码 – NIKHIL 2011-06-07 09:17:48
我应该在哪里写这个code.And你能解释更多更好的理解 – Ajay 2011-06-08 09:05:07