2011-06-07 5 views
4

私は非常に混乱しています。どのように契約書のページをアプリケーションの使用時に1回だけ表示することができますか?私はこれをどのように説明することができません。しかし、私はこれを説明しようとしています。 私が (1)ボタンの名称は (2)ボタン名は、ユーザーがクリックした場合は[Accept]ボタンのアプリケーションは、次のページに入るページの開封に伴う問題(ライセンス契約ページ)

拒否で受け入れている2つのボタンを持っている契約のページを持っているアプリケーションを作成していますしかし、ユーザが拒否ボタンをクリックすると、アプリケーションからアプリケーションが終了します。 しかし、ひねりがここにあります このアプリケーションを初めて実行すると、契約ページが表示され、ユーザーがこの契約に同意すると、彼は遠くに移動します。 しかし、ユーザーがこのアプリケーションを何度も何度も使用した場合、彼は既に契約に同意した場合、再度契約ページを見てはいけません。 どうすればこの問題を解決できますか非常に混乱しています。 ありがとうございます

答えて

4

ユーザーはあなたが合意の値(おそらくBollean)を格納よりも契約書に同意した場合は、おそらくのドキュメントディレクトリから(plistファイルにアルタービューを通じて

を契約ページを適用することができますそれは一度

のために受け入れられると協定を表示しないようにするためのアプリ)の各時間より を、あなたはそれを

enter image description here

CODEを確認することができます

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

    } 
+0

私はこれをどうすれば説明できますか? – Ajay

+0

更新されたコードを確認してください – NIKHIL

+0

どこにこのコードを書くべきですか?より良い理解 – Ajay

3

あなたのアプリをiTunes Connectに送信するときに、このライセンス契約を締結するのが最善の解決策です。それには特別な場所があります。そう

ユーザーは、彼が

チェック「iTunesConnect DeveloperGuide」ページの「EULA」の部分52

が、それはあなたを助け願っています最初の場所でアプリをインストールしません同意しない場合。

+0

が、その任意のコードのIされているディレクトリを文書化するのplistをコピー// plistの設定値AS UNCHECKED(REJECTED STATE)に

を1つのブール変数を追加リソースフォルダにで
を1つのplistファイルを追加ちょうどあなたが、私はEULA – Ajay

+0

を記述する必要が ページ52 –

+0

を接続し、iTunesのEULAを追加し、無 – Ajay

関連する問題