2011-11-30 65 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獲取對單元格的訪問權限。

相關問題