See the code:
@implementation UIView (ios7)
- (void)layoutSubviews
{
[self layoutSubviews];
// ......
}
Obviously ,this will result in “Infinite recursion”. Super is not helpful either. I just want to add some code to a common fucntion in a common class,and do not think Inherit will help. So,is their any way to do this.Or my requirement is just stupid. Thanks!
++++++++++++++++++++++++++
@interface CPUIView :UIView
- (void)layoutSubviews;
@end
...
@implementation CPUIView
- (void)layoutSubviews
{
[super layoutSubviews];
// add some code
}
@end
@implementation UIView (CP)
+ (Class)class
{
return NSClassFromString(@"CPUIView");
}
I think this code will help me with my problem,I just want to rewrite the layoutSubviews function for the UIView .Thus, any UIView class in my project will do what I want then to do in this function.