在宏中添加条件

时间:2014-02-13 09:22:00

标签: uitableview ios7 uialertview

如何在宏

中添加以下条件

if(![NSStringFromClass([[self superview] class])isEqualToString:@“_ UIModalItemAlertContentView”])

我想仅在tableView类别的superClass不是alertView

时添加这两个方法
#if ([NSStringFromClass([[self superview] class]) isEqualToString:@"_UIModalItemAlertContentView"])

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if ([self.customDelegate respondsToSelector:@selector(tableView:touchBegan:withEvent:)]) {
        [self.customDelegate tableView:self touchBegan:touches withEvent:event];
    }

    [super touchesBegan:touches withEvent:event];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if ([self.customDelegate respondsToSelector:@selector(tableView:touchEnded:withEvent:)]) {
        [self.customDelegate tableView:self touchEnded:touches withEvent:event];
    }
}

#endif

1 个答案:

答案 0 :(得分:0)

#define YourMacroName(_view_) ([NSStringFromClass([[_view_ superview] class]) isEqualToString:@"_UIModalItemAlertContentView"])

if(YourMacroName){
   //do something
}

这是你想要的吗?