3 つの異なるテーブルと、ラベルを含む単一の UiView があるアプリを開発しています。その選択したテーブルビューセル名の表示名をラベルに設定したい。
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AppDelegate * appdelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
if(appdelegate.btn1)
{
appdelegate.selectId=indexPath.row;
NSLog(@"select Id %d",appdelegate.selectId);
}
else if(appdelegate.btn2)
{
appdelegate.selectId=indexPath.row;
NSLog(@"select Id %d",appdelegate.selectId);
}
else if(appdelegate.btn3)
{
appdelegate.selectId=indexPath.row;
NSLog(@"select Id %d",appdelegate.selectId);
}
NSString * str=[appdelegate.name objectAtIndex:indexPath.row];
NSString * str1=[appdelegate.iname objectAtIndex:indexPath.row];
NSString * str2=[appdelegate.bname objectAtIndex:indexPath.row];
DetailViewController * dvc=[[DetailViewController alloc]initWithTrick:str andOtherString:str1 andOtherString:str2];
[self.navigationController pushViewController:dvc animated:YES];
}
そして、そのセル名にinitメソッドにアクセスします。
-(id)initWithTrick:(NSString *)name_ andOtherString:(NSString *)name2_ andOtherString:(NSString *)name3_;
{
if (self)
{
self.trickname=name_;
self.trickname2=name2_;
self.trickname3=name3_;
}
return self;
}
ここで、trickname、trickname2、trickname3 は NSString です。
このコードを試しましたが、うまくいきません。
これを手伝ってください。