Archive for 4月 3rd, 2014

UIAlertViewのテキストのUIAlertViewStylePlainTextInputでの既定値の追加方法

木曜日, 4月 3rd, 2014

UIAlertViewのテキストのUIAlertViewStylePlainTextInputでの既定値の追加方法
えー、色々調べてもわからなかったのですが。


                UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"ReName Folder"
                                                                message:@"NewFolder Name Input"
                                                               delegate:self
                                                      cancelButtonTitle:nil
                                                      otherButtonTitles:@"OK", nil];
                [alert addButtonWithTitle:NSLocalizedString(@"Cancel",@"OK")];
                alert.delegate       = self;
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;

                [alert show];

どうするかというと、

[alert textFieldAtIndex:0].text=@”Defualt Strings”;

を[alert show]; の前に設置です。
以下の感じです。


                UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"ReName Folder"
                                                                message:@"NewFolder Name Input"
                                                               delegate:self
                                                      cancelButtonTitle:nil
                                                      otherButtonTitles:@"OK", nil];
                [alert addButtonWithTitle:NSLocalizedString(@"Cancel",@"OK")];
                alert.delegate       = self;
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;
                [alert textFieldAtIndex:0].text=[NowDir lastPathComponent];

                [alert show];