2010-09-10
■ とあるアイディア… 
d:id:yamaryoxxxx:20100908#1283952232
実は最初に作ったアプリはまさにこれ。
「RemoteVibe」ってやつ作った。P2P通信でiPhone2台で…(ry
社内では発表したんだけど、Appleの審査通れず無念な思いをした。
機会があればどこかで出したい。
2010-05-25
2010-05-24
■ [NSThread]NSThreadを使ったスレッド処理 
スレッドを生成するには detachNewThreadSelector を使う。
実行されるメソッド自体が自動解放プールの管理を行う必要がある。
[NSThread detachNewThreadSelector:@selector(hogehoge) toTarget:self withObject:self]; - (void)hogehoge { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // 処理 [pool release]; [NSThread exit]; // 途中でスレッドを終了する }
2010-04-14
■ [Xcode]iPhone SDK4 beta入れて新規プロジェクトを作り3.xモードで動かすとエラーになる 
新規プロジェクト作って、何も変更せずにそのまま動かしただけ。
シミュレータ(Ver 3.1.3)で動かすと落ちる。こんなエラーが出ている。
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIWindow 0x391e740> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key rootViewController.'
海外の掲示板とかでも同様の問題が報告されている。
だけど、解決策は分からず…。
Xcode戻すしかないのかなぁ。
■ [book]「はじめてのiPhone3プログラミング」 
「Beginning iPhone Development」の翻訳本。
最近買ってみたんだけど、この本いいね。説明しっかりしてるし、内容も十分。
- 作者: Dave Mark,Jeff LaMarche,鮎川不二雄
- 出版社/メーカー: ソフトバンククリエイティブ
- 発売日: 2009/12/17
- メディア: 大型本
- 購入: 16人 クリック: 86回
- この商品を含むブログ (26件) を見る
2010-04-13
■ [デザイン]アプリケーションアイコンに光沢がつかないように設定する方法 
昨日iPhoneを見ていたら、アプリのアイコンに"光沢"がついているものとついていないものがあることに気が付いた。
これって、どこかで設定できるのだろうかと。
「iPhoneヒューマンインターフェイスガイドライン(PDF)」を読んでいたら、その答えがあった。
選択すれば、Phone OSがアイコンに光沢を追加しないようにすることもできます。それには、
アプリケーションのInfo.plistファイルにUIPrerenderedIconキーを追加します
2009-12-27
KishikawaKatsumi*.js はデフォルトでソースファイルとして扱われるのでバンドルに含まれないんですよ。
ターゲット>[アプリ名]>ソースをコンパイル
と開いて、*.js ファイルを「バンドルリソースをコピー」の方にドラッグして、再ビルドすればバンドルから読み込めるようになります。
ちなみに、
[[NSBundle mainBundle] pathForResource:@"filename.txt" ofType:nil];
のように、リソース名に拡張子を含めれば、2つ目の引数は無くてもいいです。
soheiKishikawaKatsumi様、
なるほど、そういうことなんですね。理解できました。御丁寧に説明ありがとうございました!
2009-12-23
■ [UIAccelerometer][UIAcceleration]加速度センサを使う 
- (void) testAccelerometer { // 加速度センサのインスタンスを作成 UIAccelerometer* accelerometer; accelerometer = [UIAccelerometer sharedAccelerometer]; accelerometer.updateInterval = 0.3f; accelerometer.delegate = self; } // 加速度センサ検出 - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration { NSLog(@"x=%f, y=%f, z=%f", acceleration.x, acceleration.y, acceleration.z); }
このように簡単に取得できるんだけど、これをどう使うかが難しいところだね…。
振ったのを検出するのに、とりあえずこんな感じでやってみた。もっと良い方法あるかなぁ?
accelerometer.updateInterval = 0.3f; if(abs(acceleration.x) > 0.3 || abs(acceleration.y) > 0.3) {
2009-12-20
■ [CALayer][CABasicAnimation]レイヤーを使ったアニメーション 
アニメーションの処理方法は3種類あるで書いた2つめの方法。
レイヤーを使った方法だとこんな感じ。
UIImage* image=[UIImage imageNamed:@"image.png"]; //レイヤーの生成 CALayer* layer=[CALayer layer]; [layer setBounds:CGRectMake(0,0,image.size.width,image.size.height)]; [layer setPosition:CGPointMake(60,60)]; [layer setContents:(UIView*)image.CGImage]; [self.view.layer addSublayer:layer]; //レイヤーアニメーションの生成 CABasicAnimation* anime=[CABasicAnimation animationWithKeyPath:@"position"]; anime.duration = 1.0f; anime.autoreverses = YES; anime.repeatCount = 999; CGPoint position = layer.position; anime.fromValue = [NSValue valueWithCGPoint:position]; position.x += 200; anime.toValue = [NSValue valueWithCGPoint:position]; [layer addAnimation:anime forKey:@"anime"];
アニメーションを停止するには、removeAnimationForKey メソッドを使う。
[layer removeAnimationForKey:@"anime"];
2009-12-18
■ [UIView][CALayer]アニメーションの処理方法は3種類ある 
簡単さ手軽さの順で言えば、3>1>2かな。本格的にやるなら2。
※アニメーションの処理については、オライリー本にはあまり書かれていなくて、「iPhone SDK プログラミング大全」の書籍にけっこう書かれていました。
■ [UIView]UIView Animation 
上で紹介した方法の1番目の方法。
UIView のアニメーション機能で簡単に使えます。
こんな感じです。
UIImageView* _imageView; - (void)loadView { [super loadView]; //イメージビュー生成 _imageView=[[UIImageView alloc] init]; UIImage* image=[UIImage imageNamed:@"image.jpg"]; [_imageView setImage:image]; [_imageView setFrame:CGRectMake(0,0,image.size.width,image.size.height)]; [self.view addSubview:_imageView]; [self testAnimetion]; } - (void) testAnimetion { //アニメーションの開始 [UIView beginAnimations:@"testAnimation" context:NULL]; [UIView setAnimationDuration:0.1f]; // 時間 [UIView setAnimationCurve:UIViewAnimationCurveLinear]; // 加速パターン [UIView setAnimationDelegate:self]; // デリゲート [UIView setAnimationRepeatAutoreverses:TRUE]; // リバース動作 [UIView setAnimationRepeatCount:999]; // 繰り返し回数 [UIView setAnimationDidStopSelector:@selector(animationDidStop:)]; //イメージの移動 CGRect frame=_imageView.frame; frame.origin.x=50; // xが 0〜50 まで移動 _imageView.frame=frame; _imageView.alpha=0; // 透明度を0に //アニメーションの終了 [UIView commitAnimations]; } //アニメーション完了イベント - (void)animationDidStop:(NSString*)animationID finished:(BOOL)finished context:(void*)duration { NSLog(@"アニメーション完了"); }
beginAnimations から、commitAnimations までの間で、アニメーションの動作を記述します。
繰り返しの設定やリバース動作も設定できで、簡単ですね。
ここを参考にさせていただきました。
http://www.saturn.dti.ne.jp/~npaka/iphone/ViewAnimeEx/index.html



僕も3.2ベータで同じ目に遭いました。
もうベータ版はインストールしないと心に誓いましたw