インストールしておくと幸せになれるアプリケーション
- Unity3D
Unityで開発するんだからUnity入れないと!
フリー版でも十分に開発できる。 -
Xcode
iPhoe用ビルド出力時やgitのインストールで必要になる。 -
FBX viewer
デザイナから受け取ったデータを確認するのに必要。 -
Blender
無料DCCツール。自前でAnimatorの使い方とかを勉強する際に使い方を覚えておくと便利。
Xcode
iPhoe用ビルド出力時やgitのインストールで必要になる。
FBX viewer
デザイナから受け取ったデータを確認するのに必要。
Blender
無料DCCツール。自前でAnimatorの使い方とかを勉強する際に使い方を覚えておくと便利。
ここに凄くシンプルな方法が載っていたのでまとめ。
http://stackoverflow.com/で載っていたサンプル
Cellは基本的に表示してる領域+前後いくつか分のViewしか持たないのでCellそのものにデータ保持をさせるのは危険。
独立したUITableViewCellクラス専用に1つのXibを持たせる。
Cell自身がXibを呼び出すので、他のサイトで載っているようなController側が保持するやりかたのように複雑風にならない。
#import @interface Cell : UITableViewCell { NSNumber* num_; @private IBOutlet UILabel* label1_; IBOutlet UILabel* label2_; IBOutlet UIImageView* icon_; } @property (nonatomic,strong) UILabel* label1; @property (nonatomic,strong) UILabel* label2; @property (nonatomic,strong) UIImageView* icon; + (Cell*)cellFromNibNamed:(NSString *)nibName; @end
#import "Cell.h" @implementation Cell @synthesize label1 = label1_; @synthesize label2 = label2_; @synthesize icon = icon_; + (Cell *)cellFromNibNamed:(NSString *)nibName { NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:NULL]; NSEnumerator *nibEnumerator = [nibContents objectEnumerator]; Cell *customCell = nil; NSObject* nibItem = nil; while ((nibItem = [nibEnumerator nextObject]) != nil) { if ([nibItem isKindOfClass:[Cell class]]) { customCell = (Cell *)nibItem; break; // we have a winner } } return customCell; } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { NSLog(@"%s",__func__); self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; }
このクラスメソッドでは何でも格納ObjectNSArray型のnibContentsにXibを読み込んで格納し、列挙型NSEnumeratorを生成。
Xib内に独自Cell用のnibがあったら返してもらい、それを以てCellとし、列挙を離脱。
最後にCellを返して終了する、という流れ。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { cell = [tableView dequeueReusableCellWithIdentifier:@"orgCell"]; if (cell == nil) { cell = (Cell *)[Cell cellFromNibNamed:@"Cell"]; cell.label1.text = @"test"; } return cell; }
ここでは先のCellで定義したNibを読み込んでViewを生成するクラスメソッドを呼び出して格納している。
label1.textはviewに載っているLabelにIBOutletで接続したUILabelへの接続。独自に作ったXibに合わせて変更を。
また、Cellにコントローラを埋める場合はCellの使い回しをセルの種類単位で分けないとぐちゃぐちゃになるとの事。
必ずFloat型の数値を返しておくこと。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s",__func__); return 100.0; }
セルを生成しなおしたりできる。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s",__func__); }
変更をデフォルトに戻しておく。
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ NSLog(@"%s",__func__); }
File’sOwnerのCustomClassの項目はMasterViewControllerにしておく。
※これは記述無しでも駆動する。記述が無い場合はデフォルトの値が入るので、Cell
Cell側のCustomClassの項目はCellにする。
IBOutlet付きのメンバはCell下のLabel – Label1等に直接接続する。
UITableViewCellはデフォルトでUILabelを複数保持している。
これらのプロパティ名はtextLabelとdetailTextLabelなのでこれらの既存プロパティをメンバ変数と一緒に扱う事で上書きができる。無為にプロパティを増やさなくて済む。
Cell.h
@interface Cell : UITableViewCell { NSNumber* num_; @private IBOutlet UILabel* label1_; IBOutlet UILabel* label2_; IBOutlet UIImageView* icon_; IBOutlet UILabel* detailTextLabel_;//既存プロパティ用に追加。 IBOutlet UILabel* textLabel_;//既存プロパティ用に追加。 }
Cell.m
@synthesize detailTextLabel = detailTextLabel_; @synthesize textLabel = textLabel_;
これで既存プロパティと共通化させる事が出来た。
このメモはSBJson frameworksに関するもの。
記述時点での正式リリースバージョン3.0.4
参考:http://stig.github.com/json-framework/api/3.0/
ARC適用する場合は3.1α以降でなければ動作しない。
http://ip7.biz/wordpress/?p=1008
git clone git://github.com/stig/json-framework.git
_OBJC_CLASS_$_SBJsonParser", referenced from:
#import
@class SBJsonStreamParser;
@class SBJsonStreamParserAdapter;
//read file NSString* fileName = [NSString stringWithFormat:@"dummyData"]; NSString* path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Documents"]; path = [path stringByAppendingPathComponent:fileName]; NSData* data = [NSData dataWithContentsOfFile:path];
if(data == nil) abort();
//Data encode to NSString. NSString* dataStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"data = %@",dataStr);
//SBJson parse to NSDictionary. SBJsonParser* sbjsonparser =[[SBJsonParser alloc]init]; NSError* error; error = nil; NSDictionary* dic = [sbjsonparser objectWithString:dataStr error:&error]; NSLog(@"JSON dictionary=%@", [dic description]);
{ "buttonArray":[ { "word":"キウイ", "imgPath":"greenButtons_0000s_0003.png" }, { "word":"うみがめ", "imgPath":"redButtons_0000s_0003.png" } ] }
CoreData[39477:fb03] JSON dictionary={ buttonArray = ( { imgPath = "babylogButtons_0000s_0003.png"; word = "U30adU30a6U30a4"; }, { imgPath = "babylogButtons_0000s_0003.png"; word = "U3044U3061U3054"; } ); }
むしろXcode4.3.2でもダメなのでXcode4.3.xにしてしまった人はXcode4.3を別途DLしておく必要がある。
またUnity側でBuildSettingsからターゲットOSをiOS5.0にしておくとさらに安全。
”さらに安全”と言ってるのは原因が定かでないし手順もこれが最小限かも分からないから。
AppStoreでXcodeをUpgradeしてしまったら別途DLしたXcode4.3の名前を変えて併存させる。
左がAppStore管轄の最新版。右は別途DLした4.3。
で、Xcode4.3ではiOS5.1にはアプリをコピーできない問題がある。
しかし以下の手順を踏むとなぜかコピーできてしまう。
接続中のiOSデバイスへのコピーが行われるが実機起動後にSplashScreenを変えただろあんた!ダメだっつってんだろ!と起こられて起動停止する。
ちなみに、一度ビルドが成功してコピーも完了するとなぜかUnity側でiOS5.1向けとしてBuildしてもコピー可能になる。
Xcode4.3ではiOS5.1向けのビルドは通らないはずで、そもそも4.3.1はiOS5.1向けとしてリリースされた経緯があるほどバージョンには違いがあるのだが…。
Xcode4.3.1/Xcode4.3.2で実機にコピーして立ち上げる過程で何かが起こってるのだろうか…。
※Xcode4.3.2の画面。Retina Displayの項目が空白に。これが関係してるんだと思われる。
※これがXcode4.3の画面。RetinaDisplayの項目は無い。
ちなみにこのバージョンでも続いているSpalashScreenイナイイナイ問題はUnity側は感知しているのでUnity3.5.1がリリースされるまでは解決しない見込み。
ただし、プロ版を買えばSplashScreenなんて変え放題なので問題は解決する。
main内で止まるとバグを追いにくくてハマるのでできるだけ追いやすい様にと色々調べてみた。
NSLogだけじゃない、こんな方法あんな方法、まず知っておく。
Xcode左上のプロジェクトを選択して環境
3つの環境変数を追加できたらOKボタン。
gdbはデバッグ時に使えるコマンド。
Xcodeの最下部のコンソールに入力して様々な情報を得る事ができる。
詳しくはApple のdebugging with gdbを参照。
チートシートも見つけたのでよかったらどうぞ。
http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf