English 中文(简体)
A. 如何确定一个电池是否含有一个纽子
原标题:How to determine if a cell contains a button

I ve创建了一个名为CELL的电池。

My first task is add a button on the cell, which I have successfully added. However, while retrieving the CELL I need to know if the cell is the reusable cell or not. If not, then create the cell and add the button, but if the cell exists and button does not, I need to add the button.

In my XIB I added the button in the cell. In some cells I need to show the button and in some I don t.

我如何确定牢房是否包含一个纽子? 如果它包含一个纽州,我会把它归谁?

最佳回答

One approach is to iterate though subview which I personally think is bad idea. The other approach is to set the tag of the cell say 100 for containing button.

然后可以检查

if (cell.tag == 100) {
     // Cell with button
} else {
     // Cell without button
}
问题回答

用途:

for( int i =0 ; i < [cell.subviews count]; i++) {
    if ([[cell.subviews objectAtIndex:i] isKindOfClass:[UIButton Class]] ) {
        //Button is found, do whatever you want
        UIButton *button = [cell.subviews objectAtIndex:i];
        int tag = button.tag;
    }
}




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签