Created
April 11, 2012 21:07
-
-
Save dbrajkovic/2362588 to your computer and use it in GitHub Desktop.
UIView Tag Categories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+TagExtensions.h | |
// | |
// Created by Daniel Brajkovic on 2/19/12. | |
#import <UIKit/UIKit.h> | |
@interface UIView (TagExtensions) | |
- (UIButton *)buttonWithTag:(NSInteger)aTag; | |
- (UIImageView *)imageViewWithTag:(NSInteger)aTag; | |
- (UILabel *)labelWithTag:(NSInteger)aTag; | |
- (UIScrollView *)scrollViewWithTag:(NSInteger)aTag; | |
- (UITextField *)textFieldWithTag:(NSInteger)aTag; | |
- (UITextView *)textViewWithTag:(NSInteger)aTag; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+TagExtensions.m | |
// | |
// Created by Daniel Brajkovic on 2/19/12. | |
// | |
#import "UIView+TagExtensions.h" | |
@implementation UIView (TagExtensions) | |
- (UIButton *)buttonWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UIButton class]]) { | |
return (UIButton *) aView; | |
} | |
return nil; | |
} | |
- (UIImageView *)imageViewWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UIImageView class]]) { | |
return (UIImageView *) aView; | |
} | |
return nil; | |
} | |
- (UILabel *)labelWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UILabel class]]) { | |
return (UILabel *) aView; | |
} | |
return nil; | |
} | |
- (UIScrollView *)scrollViewWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UIScrollView class]]) { | |
return (UIScrollView *) aView; | |
} | |
return nil; | |
} | |
- (UITextField *)textFieldWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UITextField class]]) { | |
return (UITextField*) aView; | |
} | |
return nil; | |
} | |
- (UITextView *)textViewWithTag:(NSInteger)aTag | |
{ | |
UIView *aView = [self viewWithTag:aTag]; | |
if (aView && [aView isKindOfClass:[UITextView class]]) { | |
return (UITextView *) aView; | |
} | |
return nil; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment