ラベル storyboard の投稿を表示しています。 すべての投稿を表示
ラベル storyboard の投稿を表示しています。 すべての投稿を表示

2012年1月3日火曜日

[iOs][storyboard]別ファイルからのnibの読み込み


[storybordからの取得]
EnemyStoryboard* st =[UIStoryboard storyboardWithName:@"EnemyStoryboard" bundle:nil]


[nibからの取得]
EnemyView* v= [[NSBundle mainBundle] loadNibNamed:@"EnemyView"
                             owner:self options:nil]lastObject];

EnemyViewController* vc=[[EnemyViewController alloc]
                             initWithNibName:@"EnemyViewController" bundle:nil];



(おまけ)
アウトレットの配列管理

@property (strong, nonatomic) IBOutletCollection(UIImageView) NSArray *damagePoint;

2011年12月6日火曜日

[ios][storyboard]ストリーボードの動作を確認してみた


まず、よくストリーボードでviewControllerからviewControllerをつなぐsegueをモーダルで画面遷移を定義していくが、AからBへいってBからAに戻る遷移をモーダルでつなぐ人がいたので、それはさすがに違うだろうと思うので実際確認してみた。

- (void)viewDidAppear:(BOOL)animated
{
    NSLog(@"%@",self);
    [super viewDidAppear:animated];
}


2011-12-06 00:26:53.328 modaltest[25564:f803]
2011-12-06 00:26:56.094 modaltest[25564:f803]
2011-12-06 00:27:04.040 modaltest[25564:f803]
2011-12-06 00:27:05.722 modaltest[25564:f803]
2011-12-06 00:27:09.271 modaltest[25564:f803]
2011-12-06 00:27:11.272 modaltest[25564:f803]

当たり前だけど、違うメモリアドレスを返してくる。やはり、モダールはちゃんと
dismissは自分で実装しないといけないみたい。
メモリは同じなので、遷移のスタックがたまっていってるのかな。


資料を探して行き詰まっていたけど、なんだかんだでたよりになるのは
テンプレートのソース。

リストテンプレートを見ればsegueからデータを次のviewControllerに渡す方法も分かる。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    if ([[segue identifierisEqualToString:@"showDetail"]) {

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSManagedObject *selectedObject = [[self fetchedResultsControllerobjectAtIndexPath:indexPath];
        [[segue destinationViewControllersetDetailItem:selectedObject];
    }
}


リストテンプレートにCoreDataをチェックして作れば、動的Propetyでの利用の仕方が分かる。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];    return cell;
}
カスタムセルが作りやすくなっている気がします。

意外と使えるかも、ストリーボード!