2012年9月3日 星期一

Testing

Testing

2012年1月12日 星期四

如何讓你的app可以分享其他app當中的檔案。 how to share document from other app?

如何在別的app當中利用 Open-in 分享該擋給我的app?

app-Info.plist當中加入一個鍵值


CFBundleDocumentTypes

CFBundleTypeIconFiles

檔案的縮圖_320.png

檔案的縮圖.png

CFBundleTypeName

COD

CFBundleTypeRole

Viewer

LSHandlerRank

Owner

LSItemContentTypes

com.cotton.app.cod

public.comma-separated-values-text



如果你的app想接受或是開啓的檔案形態是自己新創建的 例如;我自己弄了一個 副黨名是 .cod 的檔案。

則需要加一個 export type 的描述鍵值是UTExportedTypeDeclarations

UTExportedTypeDeclarations

UTTypeConformsTo

public.data

UTTypeDescription

MyAppName File

UTTypeIdentifier 檔案形式的識別碼(必須獨一無二的,官方文件上建議用com.公司名稱.app名稱.副檔名來表示)-->

com.cotton.app.cod

UTTypeTagSpecification

public.filename-extension

cod

public.mime-type

application/octet-stream


2011年12月25日 星期日

Error launching remote program: failed to get the task for process XXX.

原因;使用了distribution provisioning profile 在debug環境上。
解決方式;把 provisioning profile 換成debug用的。

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);

}

}


// 列出app文件夾下的檔案
// list out all files under apple document directory

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?

///to get know the device is iPhone or iPod touch ...
NSString deviceType = [[UIDevice currentDevice] model] ;
/// if the device is iPhone, pick up the phone number
if ( [deviceType isEqualToString:@"iPhone"] ) {
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"];
NSLog(@"phone number:%@",num) ;
}

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.


如果用到tabbar,在tabbar item的icon大小
30x30, 60x60 灰階 png 檔。