2013年3月8日金曜日

[iOS]Enumeration values * not handled in switch


Enumeration values * not handled in switch

列挙子*はswitchで処理されていません。
つまりswitchで列挙子をすべて網羅する必要がある。

2013年3月4日月曜日

[iOS]iOS4.3~5.1~6.1に回転対応をする

あらかじめ[appname].plistSupported interface orientationsを設定する必要がある。

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //iOS 4.3~5.1 回転時の呼び出しメソッドを設定
    
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    //iOS 4.3~5.1 回転の停止
    //他のViewControllerで使用したくないときはここでキャンセルする
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:UIDeviceOrientationDidChangeNotification
                                                  object:nil];
}

//iOS 6.0~ 回転をサポートするか
- (BOOL)shouldAutorotate
{
    return YES;
}

//iOS 6.0~ 推奨される向き
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

//iOS 6.0~ サポートする向き
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

//iOS 4.3~5.1 回転をサポートするか?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

//回転時の動作
- (void)orientationChanged:(NSNotification *)notification
{

}

//回転時のアニメーションを定義
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{

}

//回転前に呼び出される
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

}

2013年2月19日火曜日

[iOS]This bundle is invalid.

This bundle is invalid. The key CFBundleVersion in the info.plist file must contain a higher version than that of the previously uploaded version.

iTunesConnectに審査提出中にOrganaizerで上記のエラーが発生した。

CFBundleVersionが前のバージョンより新しくしてください、
ってことなんだけど、1.1.0から1.1.1でもちろん新しくなってる。

原因は
plistからBundle versionが抜けていた。

Target>SummaryのVersionって修正してもplistに反映されないのね。

2013年2月18日月曜日

[iOS]NSPersistentStoreCoordinatorでエラー


Coredataを使用中に
persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
でエラーを吐いた。
persistentStoreCoordinator_
を生成できないらしい。

現象は
http://stackoverflow.com/questions/4199466/core-data-crash-in-initwithmanagedobjectmodel
と同じで、appname.xcdatamodeldのファイルがおかしいらしい

appname.xcdatamodeldがxCode上から開けない状態だったので、
一度xCode上から削除して再度インポートするとエラーは消えた。

他にもxcdatamodeldが前のバージョンと違ってもこのエラーらしいね。

2013年2月8日金曜日

[iOS]iPadのサイズとか

iPhoneサイズ
320x480
640x960
640x1136

ステータスバーを省いたサイズ
320x460
640x620
640x1096

iPad、iPadMiniサイズ
Portrait 768 x 1024
Landscape 1024 x 768

ステータスバーを省いたサイズ
Portrait 768 x 1004
Landscape 1024 x 748


iPad(Retina)サイズ
Portrait 1536 x 2048
Landscape 2048 x 1536

ステータスバーを省いたサイズ
Portrait 1536 x 2008
Landscape 2048 x 1496


2013年1月23日水曜日

[AndroidSDK]MapViewが表示されない

AndroidSDKにてMapViewことGoogle Map APIが動作しない事態になった。
MapView自体は表示されているが、地形データ等のダウンローができない状態。

エラーログには

IOException processing: 26
java.io.IOException: Server returned: 3

と表示された。

・ソース上のミスをチェック、、無し
・Google MAP API Keyは正しいか、、、正しい

少し考えこんで署名が無いことに気づいた。
Google MAP API Keyはアプリ署名に紐付けられているので、
署名付きアプリとしてAPKを書き出したところ表示された。


2013年1月21日月曜日

[iOS]iPhoneでゲームを作る方法

ゲームを作ることになったので、iPhoneでゲームを作る方法を考えてみる。
現在4通りほど考えられる。


CoreAnimetion
UIViewとCGContextRefなどを使う方法
ゲームのために作られてるわけじゃないから複雑なことを実装するとコケる可能性がある

OpenGL1.1/2.0
パフォーマンスが良い3D/2Dエンジン、本格的に作るならこっちだろう
習得に時間がかかりそうだ、1週間やそこらで十分に扱うのは難しいだろう

強火で進め
http://d.hatena.ne.jp/nakamura001/20080918/1221738923

OpenGL1.1リファレンス
http://www.khronos.org/opengles/sdk/1.1/docs/man/

cocos2d
iOS向き2Dゲームワークフレーム
実績が無数にある、修得も簡単
中身はOpenGLES1.1

http://www.cocos2d-iphone.org/

corona
モバイル向きワークフレーム
重力エンジンなどがある、修得も比較的簡単

http://jp.anscamobile.com/corona/

salad
コード不要でGUIベースで簡単なゲームを作成する

http://gamesalad.com/