2011-11-30 125 views

回答

0

将属性添加到指向单元格的按钮,或者如果btnPlus是单元格的子视图,则使用btnPlus.superview.textlabel.text

0

设置标签到按钮和标签,然后你可以得到标签文本 使用视图与标签选项

0

变化@selector(plusButtonPressed)到@selector(plusButtonPressed :)(注意添加在末端结肠)

然后在

- (void)plusButtonPressed:(UIButton*)sender { 
    NSString *theText = sender.superview.textlabel.text; 
} 

(这是假设的加号按钮被添加到UITab的内容查看leViewCell)

+0

这是我创建自定义单元格作为这样的单独的类。 CustomCell * cell =(CustomCell *)[[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier] autorelease];如果(细胞==无){ \t \t的NSArray *笔尖= [[一个NSBundle mainBundle] loadNibNamed:@ “CustomCell” \t \t \t \t \t \t \t \t \t \t \t \t \t所有者:自选项:无]; \t \t为(在笔尖ID oneObject)如果([oneObject isKindOfClass:[CustomCell类]]) \t \t \t细胞=(CustomCell *)oneObject; \t \t \t} – sajaz

+0

如果您使用的是厦门国际银行与细胞,而不是在代码中创建的动作,电线它在Interface Builder去选择在CustomCell类,那么你可以访问自己。直接使用textLabel.text属性 – BarrettJ

+0

是的,我有与Xib分开的类。但是我怎样才能从这个类中取回文本标签(不是Customcell类)。如果你可以给我一个代码示例,那么它非常值得赞赏,因为Im仍然是iOS SDK的新手 – sajaz

0

组标签电池:

cell.contentView.tag = indexPath.row+10000*indexPath.section; //or any you like 
[cell.contentView addSubview:button]; 

然后,在按钮的回调:

int raw=0; 
int section=0; 
long tag = [sender superview].tag; 
NSLog(@"tag: %ld", tag); 
for (int i = 0; i<[data count]; i++) { 
    if (tag>=10000) 
    { 
     tag-=10000; 
     section++; 
    } 
    else i = [data count]; 
} 
raw = tag; 

现在,你可以完全访问您的细胞。使用计算的rawsection ta获取对单元格的访问权限。

相关问题