2013-04-05 50 views
2

我喜歡保存圖像稱爲img到iTunes的文件共享文件夾。有人可以告訴我如何?如何將圖像保存到iTunes的文件共享

+1

如果你簡單地存儲您在文檔目錄中的圖像將會在iTunes文件共享中顯示。 – 2013-04-05 11:45:24

+0

http://stackoverflow.com/questions/2264039/uiimage-saving-image-with-file-name-on-the-iphone – 2013-04-05 11:46:05

+0

你想是這樣的http://www.raywenderlich.com/1948/how -integrate-iTunes的文件共享與 - 您 - IOS-應用 – satheeshwaran 2013-04-05 11:52:21

回答

2

下面是示例代碼:

NSArray paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDir = [paths objectAtIndex:0]; 
NSString *filePath = [NSString stringWithFormat:@"%@/%@.jpg", documentsDir, filename]; 

NSData data = UIImageJPEGRepresentation(img, 1.0); 
[data writeToFile:filePath atomically:NO]; 

也有關iTunes文件共享:

你應該去Info.plist並添加一行

Application supports iTunes file sharingYES

+1

請記住,你需要啓用iTunes文件共享在Xcode – arnoapp 2013-04-05 12:30:52

+0

你是對的:)我編輯。記住 – 2013-04-05 12:48:36

+1

注意,如果您啓用'info.plist'鍵,不要在應用程序或iTunes應用程序描述的任何地方提到它,你的應用程序將會被拒絕。 – Desdenova 2013-04-05 13:17:11