ViewDidLoadの.mファイルには、次のコードがあります。
if (![@"1" isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:@"Name"]]) {
[[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"Name"];
[[NSUserDefaults standardUserDefaults] synchronize];
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"What is your name?" message:@"\n\n\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Send", nil];
UITextField *utextfield = [[UITextField alloc] initWithFrame:CGRectMake (9.0, 60.0, 260.0, 25.0)]; utextfield.placeholder =@"Username";
[utextfield setBackgroundColor:[UIColor whiteColor]];
[alertview addSubview:utextfield];
[alertview show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
}
ご覧のとおり、ユーザーはここに自分の名前を保存できるため、何度も何度も名前を入力する必要はありません。それに加えて、彼はそれに入ったかどうか二度と尋ねられることはありません。しかし、ロードされたときに名前を表示する代わりに、アプリは数字の1を表示します。私はここで明白なものを見逃していると思います。