Ios 如何在Objective-C中保存具有特定名称的视频文件?
首先,我有这个代码,它将我的视频文件保存在文档目录中:Ios 如何在Objective-C中保存具有特定名称的视频文件?,ios,objective-c,Ios,Objective C,首先,我有这个代码,它将我的视频文件保存在文档目录中: filePath = [NSString stringWithFormat:@"%@/Documents/%f.mp4", NSHomeDirectory(),[[NSDate date] timeIntervalSince1970]]; 其次,我有一个UIAlertView,允许用户输入他们要保存的视频的名称: UIAlertView * alert = [[UIAlertView alloc] initWithTitl
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
}
}
我要做的就是用输入到
UIAlertView
的文本指定的名称保存视频文件。为此,我需要更改此行:filePath=[nsstringstringwithformat:@“%@/Documents/%f.mp4”,nshomeditory(),[[NSDate-date]timeIntervalSince1970]代码>将文件保存为输入文本的当前日期和时间。但是,我不知道该怎么做。您是在问如何用输入的文本替换日期吗
您只需要传入字符串,您已经在使用homeDirectory执行此操作,如下所示
filePath = [NSString stringWithFormat:@"%@/Documents/%@.mp4", NSHomeDirectory(),[[alertView textFieldAtIndex:0] text]];