我有一個具有表格內容的類loginViewController。我已經將自定義單元格加載到表格的每一行。在方法cellForRowAtIndexPath我已經爲每一行創建一個按鈕,並賦予它一個標籤值。點擊這個按鈕將我們帶到新的視圖控制器logininsidesViewController。現在在logininsidesViewController類中,我想訪問我之前創建的按鈕標籤,我該怎麼做?訪問另一個類中的可用視圖單元格的內容
loginViewController.m類
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
customcell *cell=(customcell*)[tableView dequeueReusableCellWithIdentifier:@"cellcstm"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(customActionPressed)
forControlEvents:UIControlEventTouchUpInside];
[button setBackgroundImage:[UIImage imageNamed:@"add_black.png"] forState:UIControlStateNormal];
button.frame = CGRectMake(275 ,9, 25, 25);
[cell addSubview:button];
if (cell==nil)
{
//[tableView registerNib:[UINib nibWithNibName:@"customcell" bundle:nil] forCellReuseIdentifier:@"cellcstm"];
NSArray *arr12=[[NSBundle mainBundle]loadNibNamed:@"customcell" owner:self options:nil];
cell=[arr12 objectAtIndex:0];
}
for (int i=0; i<=indexPath.row; i++)
{
cell.selectionStyle=UITableViewCellEditingStyleNone;
}
if (indexPath.row==0)
{
cell.lbl.hidden=YES;
UILabel *l=[[UILabel alloc]init];
[email protected]"Login Templates";
l.frame=CGRectMake(100, 15, 180, 28);
[cell.contentView addSubview:l];
}
if (indexPath.row==1)
{
button.tag=1;
cell.img.image=[UIImage imageNamed:@"facebook.png"];
[email protected]"Facebook";
[cell.contentView addSubview:button];
}
if (indexPath.row==2)
{
button.tag=2;
cell.img.image=[UIImage imageNamed:@"g+.png"];
[email protected]"Google";
[cell.contentView addSubview:button];
}
if (indexPath.row==3)
{
button.tag=3;
cell.img.image=[UIImage imageNamed:@"youtube.png"];
[email protected]"Youtube";
[cell.contentView addSubview:button];
}
if (indexPath.row==4)
{
button.tag=4;
cell.img.image=[UIImage imageNamed:@"twitter.png"];
[email protected]"Twitter";
[cell.contentView addSubview:button];
}
if (indexPath.row==5)
{
button.tag=5;
cell.img.image=[UIImage imageNamed:@"flicker.png"];
[email protected]"Flicker";
[cell.contentView addSubview:button];
}
else
{
cell .textLabel.text= [logarr objectAtIndex:indexPath.row];
}
return cell;
}
我想訪問button.tag我logininsidesViewController類。 plz幫助