2013年1月30日水曜日

複数のボタンを同じメソッドで見分ける


複数のボタンを同じメソッドで作成する。
そのとき、識別番号(index)を渡し、Buttonのtagに設定する。

    [self thumBtn :0:@"darkr.png":71 :77 :150:172];
    [self thumBtn :1:@"batb.png"  :379:77 :120:82];
    [self thumBtn :2:@"dark.png"  :379:166:120:82];
    [self thumBtn :3:@"mada.png"  :71 :260:172:130];
    [self thumBtn :4:@"neo.png"   :353:260:174:130];

ボタン生成メソッド

-(void)thumBtn:(int)index: (NSString*)file: (int)x :(int)y :(int)w :(int)h
{
    UIImage *img = [UIImage imageNamed:file];
    UIButton *btn =[UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(x,y,w,h);
    [btn setBackgroundImage:img forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(playMovie:) forControlEvents:UIControlEventTouchDown];
    btn.tag = index; //ボタン識別用
    [imageView addSubview:btn];
}


-(void)playMovie:(UIButton*)btn{
    
    int index = btn.tag; //押されたボタンを識別する
    NSLog(@"Button:%d", index);
}

2013年1月28日月曜日

AdHoc設定

AdHoc設定

iOS Provisioning Portal siteを開く
Cetificates/Distributionタブで配布用証明書作成
デバイス追加の必要があれば、Devicesで追加(UUID必要)
Provisioning/DistributionタブでNew Profileで作成
MacにCertificates,Profileをダウンロード
Cerificatesをダブルクリック
システムにドラッグ
AdHoc Profileをダブルクリック
リフレッシュ

配布するipaをビルドする

product/Edit SchemeでArchiveがReleaseになっていること
Product/Archive、Distribute,Save for ...Ad-Hocでipaファイルを保存