I am new to iPhone development. I have a view called barView which is added as the subview to the cell, I want to check for the condition like this
if(cell has a subview barview)
{
do something.......
}else
{
do something......
}
How can 开发者_Go百科I check like this?
The simplest way is to give your barview
a special tag:
barview.tag = 123221;
and then check with
UIView* barview = [cell viewWithTag:123221];
if (barview != nil) {
...
}
Otherwise, you need to iterate through the .subviews
array and check if the property matches, e.g.
UIView* barview = nil;
for (UIView* subview in cell.subviews) {
if ([subview isKindOfClass:[BarView class]]) {
barview = subview;
break;
}
}
if (barview != nil) {
...
}
if (barView.superview == cell)
{
…
精彩评论