0

まず、ビデオ ファイルをドキュメント ディレクトリに保存する次のコードがあります。

filePath = [NSString stringWithFormat:@"%@/Documents/%f.mp4", NSHomeDirectory(),[[NSDate date] timeIntervalSince1970]];

次にUIAlertView、ユーザーが保存するビデオに必要な名前を入力できるようにする があります。

        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"GIVE YOURE VIDEO A NAME" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
        alert.alertViewStyle = UIAlertViewStylePlainTextInput;
        [alert show];

そして、私は入力されたものを表示するためにこれを持っています:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        if (alertView.alertViewStyle == UIAlertViewStylePlainTextInput){
            NSLog(@"Entered: %@",[[alertView textFieldAtIndex:0] text]);

        }


         }
    else
    {
        NSLog(@"user pressed Button Indexed 1");
        // Any action can be performed here
    }
}

私がしたいことは、.csv ファイルに入力されたテキストで指定された名前でビデオ ファイルを保存することですUIAlertView。これを行うには、次の行を変更する必要があります。filePath = [NSString stringWithFormat:@"%@/Documents/%f.mp4", NSHomeDirectory(),[[NSDate date] timeIntervalSince1970]];これにより、ファイルが現在の日付と時刻として入力されたテキストに保存されます。しかし、私はそれをどのように行うのかわかりません。

4

1 に答える 1

0

日付を入力したテキストに置き換える方法を尋ねていますか?

次のように、homeDirectory で既に行っている文字列を渡すだけで済みます。

filePath = [NSString stringWithFormat:@"%@/Documents/%@.mp4", NSHomeDirectory(),[[alertView textFieldAtIndex:0] text]];
于 2013-08-23T15:33:35.543 に答える