Tag: nsdocument

从文档目录中删除video的问题

我正试图从文档目录中删除一个video,但video并未被删除。 以下是我如何删除video: //Delete Video NSError *error = nil; //NSData *videoData = [NSData dataWithContentsOfURL:self.finalURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show];

如何从本地path加载图像ios swift(按path)

在我的应用程序中,我将图像存储在本地存储中,并将该图像的path保存在数据库中。 我怎样才能从该path加载图像? 这里是我用来保存图像的代码: let myimage : UIImage = UIImage(data: data)! let fileManager = NSFileManager.defaultManager() let urls = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) let documentDirectory = urls[0] as NSURL print(documentDirectory) let currentDate = NSDate() let dateFormatter = NSDateFormatter() dateFormatter.dateStyle = .NoStyle dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" let convertedDate = dateFormatter.stringFromDate(currentDate) let imageURL = documentDirectory.URLByAppendingPathComponent(convertedDate) imageUrlPath = imageURL.absoluteString print(imageUrlPath) UIImageJPEGRepresentation(myimage,1.0)!.writeToFile(imageUrlPath, […]

如何在文档文件夹中保存创build的PDF并在iOS中合并

更新我能够在iPHone中创build单独的带有注释的照片的PDF页面。 点击button时,我每次都会生成一个PDF页面,而我希望那些PDF页面在单个PDF页面中。 我无法将单个PDF文件合并在一起。 http://mobile.tutsplus.com/tutorials/iphone/generating-pdf-documents/?search_index=3 我已经按照上面的url代码。 你能在这里提出一些逻辑吗? 提前致谢。 * 在代码编辑 *你可以检查下面的代码。 – (IBAction)didClickOpenPDF { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",myPDFName]]; if([[NSFileManager defaultManager] fileExistsAtPath:pdfPath]) { ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfPath password:nil]; if (document != nil) { ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; readerViewController.delegate = self; readerViewController.modalTransitionStyle […]

将图像保存到文档目录并检索电子邮件附件

我无法找出NSBundle和DocumentDirectory的数据,我有一个相机图片“ imageView ”,我保存到NSDocumentDirectoy ,然后想要检索它附加到一个电子邮件, 这里的保存代码: – (IBAction)saveImage { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; UIImage *image = imageView.image; // imageView is my image from camera NSData *imageData = UIImagePNGRepresentation(image); [imageData writeToFile:savedImagePath atomically:NO]; } 这里是新的获取数据代码: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; […]