Cotton iOS blog
2012年9月3日 星期一
2012年1月12日 星期四
如何讓你的app可以分享其他app當中的檔案。 how to share document from other app?
如何在別的app當中利用 Open-in 分享該擋給我的app?
在 app-Info.plist當中加入一個鍵值
如果你的app想接受或是開啓的檔案形態是自己新創建的 例如;我自己弄了一個 副黨名是 .cod 的檔案。
則需要加一個 export type 的描述鍵值是UTExportedTypeDeclarations
2011年12月25日 星期日
Error launching remote program: failed to get the task for process XXX.
2011年12月14日 星期三
simple file management under bundle document directory 簡單的檔案管理
簡單的檔案管理
To manage the files under application's bundle document directory:
NSString *docRoot ;
// 獲取 app文件夾的位置
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docRoot = [paths objectAtIndex:0];
// 檢查app文件夾下 myfile.png 這個檔案是否存在
// to test existence of a file "myfile.png"
NSString *myFilePath = [[docRoot stringByAppendingPathComponent:@"myfile.png"]];
if ([[NSFileManager defaultManager] fileExistsAtPath: myFilePath]) {
NSLog(@"myfile.png is here!!");
}
else NSLog(@"myfile.png is not in document folder.");
// 刪除app文件夾下 myfile.png 這個檔案
// to delete the file "myfile.png"
if ([[NSFileManager defaultManager] removeItemAtPath:myFilePath error:&error]) {
NSLog(@"file deleted");
}
else NSLog(@"Delete file error: %@", error);
// 建立子資料夾
// to create sub-directory
NSString * subDirectory = [[docRoot stringByAppendingPathComponent:@"mySubDir"]];
if (![[NSFileManager defaultManager] fileExistsAtPath: subDirectory]) {
/* directory doesn't exist, create it. */
if ([[NSFileManager defaultManager] createDirectoryAtPath:subDirectory
withIntermediateDirectories:NO
attributes:nil
error:&error]) {
NSLog(@"directory %@ created.", subDirectory);
}
else {
NSLog(@"Create directory error: %@", error);
}
// 刪除子資料夾
// to delete sub-directory
if ([[NSFileManager defaultManager] fileExistsAtPath:subDirectory]) {
// subDirectory exist, delete it.
if ([[NSFileManager defaultManager] removeItemAtPath:subDirectory error:&error]) {
NSLog(@"subDirectory %@ deleted.",subDirectory) ;
}
else {
NSLog(@"Delete directory error: %@", error);
}
}
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:subDirectory error:NULL];
for (int count = 0; count < (int)[directoryContent count]; count++) {
NSLog(@"#%d: %@", (count + 1), [directoryContent objectAtIndex:Count]);
}
2011年12月13日 星期二
How to get phone number from iPhone?
2011年12月8日 星期四
捲軸畫面不捲了?scroll view Can't scroll
remember to set content size:
[myScrollView setContentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)];
2011年12月4日 星期日
開發一個iOS App 需要用到哪些圖片
file name | Size (pixels) | description |
Icon.png | 57 x 57 | Universial application icon |
Icon-settings.png | 29 x 29 | Universial application icon for settings. |
Icon~ipad.png | 72 x 72 | iPad application icon. |
Icon-spot~ipad.png | 50 x 50 | iPad icon for spotlight search. |
iTunesArtwork.png | 512 x 512 | Universial application icon for iTunes App Store.Uploaded separately to iTunes. It’s included in the app bundle too, file name: iTunesArtwork. In an iPad application iPhone OS uses this image to generate the large (320×320) document icon if it is not supplied otherwise. |
Default.png | 320 (w) x 480 (h) | iPhone/iPod 2, 3 portrait launch image |
Default@2x.png | 640 (w) x 960 (h) | iPhone 4 hi-res portrait launch image |
Default~ipad.png | 768 (w) x 1004 (h) | iPad. Specifies the default portrait launch image.This image is used if a more specific image is not available. Use full size template (768×1024) to design this launch image. The 20 pixels height statusbar is on by default and occupies the top of the screen, aka the 1004 rows vs. 1024. |
Optional icons and images: | ||
Icon@2x.png | 114 x 114 | iPhone 4 retina application icon |
Icon-settings@2x.png | 58 x 58 | iPhone 4 retina application icon for settings/search area |
Icon-doc.png | 22 (w) x 29 (h) | Universial document icon |
Icon-doc@2x.png | 44 (w) x 58 (h) | iPhone 4 retina document icon |
Icon-doc~ipad.png | 64 x 64 | iPad document icon (small size) |
Icon-doc320~ipad.png | 320 x 320 | iPad document icon (large size) |
Background-xxx.png | 320 (w) x 480 (h) 640 (w) x 960 (h) 768 (w) x 1024 (h) | background image for iPhone 2,3 G background image for iPhone 4 G background image for iPad |
Default-PortraitUpsideDown~ipad.png | 768 (w) x 1004 (h) | iPad. Specifies an upside-down portrait version of the launch image. |
Default-LandscapeLeft~ipad.png | 1024 (w) x 748 (h) | iPad. Specifies a left-oriented landscape version of the launch image. |
Default-LandscapeRight~ipad.png | 1024 (w) x 748 (h) | iPad. Specifies a right-oriented landscape version of the launch image. |
Default-Portrait~ipad.png | 768 (w) x 1004 (h) | iPad. Specifies the generic portrait version of the launch image. |
Default-Landscape~ipad.png | 1024 (w) x 748 (h) | iPad. Specifies the generic landscape version of the launch image. |
