Browse files

Added type to TBHintView. Added capability to DemoHintView to check f…

…or a certain hint type currently displayed in a UIView and to dismisss a certain hint type in a UIView.
  • Loading branch information...
1 parent 51e5b7e commit 7b40b85b5862a8eb126ba8360ba1eed3a6ee6c3e @touchbee committed May 16, 2012
View
1 TBHintView/TBHintView.h
@@ -41,6 +41,7 @@ typedef enum
@property (nonatomic,assign) TBHintViewPresentationAnimation presentationAnimation;
@property (nonatomic,assign) TBHintViewOrientation orientation;
@property (nonatomic,assign) CGFloat maximumHeight;
+@property (nonatomic,assign) NSUInteger type;
-(void) show;
-(void) show:(NSTimeInterval)duration;
View
1 TBHintView/TBHintView.m
@@ -41,6 +41,7 @@ @implementation TBHintView
@synthesize dismissTimer;
@synthesize maximumHeight;
@synthesize isDismissing;
+@synthesize type;
- (id)initWithFrame:(CGRect)frame
View
BIN ...codeproj/project.xcworkspace/xcuserdata/stefan.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
View
13 TBHintViewDemo/DemoHintView.h
@@ -21,6 +21,15 @@ typedef enum
} HintID;
+typedef enum
+{
+ kHintTypeMessage = 0,
+ kHintTypeWarning,
+ kHintTypeError
+
+} HintType;
+
+
@interface DemoHintView : NSObject<TBHintViewDataSource, TBHintViewDelegate>
typedef void (^DemoHintViewBlock)();
@@ -40,9 +49,13 @@ typedef void (^DemoHintViewBlock)();
+(void) enableHints:(BOOL)enable;
+(BOOL) hintsEnabled;
++(TBHintView*) hintInView:(UIView*)view;
+(BOOL) isHintVisibleInView:(UIView*)view;
+(void) dismissVisibleHintInView:(UIView*)view;
++(BOOL) isHintVisibleInView:(UIView*)view withType:(HintType)type;
++(void) dismissVisibleHintInView:(UIView*)view withType:(HintType)type;
+
-(void) addPageWithTitle:(NSString*)title text:(NSString*)text;
-(void) addPageWithTitle:(NSString*)title image:(UIImage*)image;
-(void) addPageWithtitle:(NSString*)title text:(NSString*)text buttonText:(NSString*)buttonText buttonAction:(DemoHintViewBlock)buttonAction;
View
52 TBHintViewDemo/DemoHintView.m
@@ -89,6 +89,7 @@ +(DemoHintView*) warningHintView
{
__block DemoHintView* basicHintView = [[[DemoHintView alloc] init] autorelease];
+ basicHintView.hintView.type = kHintTypeWarning;
basicHintView.hintView.textColor = [UIColor whiteColor];
basicHintView.hintView.backgroundColor = [UIColor colorWithRed:189.0/255.0 green:10/255.0 blue:5/255.0 alpha:0.9];
basicHintView.hintView.spanWidthWeight = 0.95f;
@@ -474,6 +475,39 @@ +(BOOL) isHintVisibleInView:(UIView*)view
}
++(BOOL) isHintVisibleInView:(UIView*)view withType:(HintType)type
+{
+ for (UIView* subview in view.subviews )
+ {
+ if( [subview isKindOfClass:[TBHintView class]] )
+ {
+ TBHintView* hintView = (TBHintView*)subview;
+ if( hintView.type == type )
+ {
+ return YES;
+ }
+ }
+ }
+
+ return NO;
+}
+
+
++(TBHintView*) hintInView:(UIView*)view
+{
+ for (UIView* subview in view.subviews )
+ {
+ if( [subview isKindOfClass:[TBHintView class]] )
+ {
+ TBHintView* hintView = (TBHintView*)subview;
+ return hintView;
+ }
+ }
+
+ return nil;
+}
+
+
+(void) dismissVisibleHintInView:(UIView*)view
{
for (UIView* subview in view.subviews )
@@ -486,4 +520,22 @@ +(void) dismissVisibleHintInView:(UIView*)view
}
}
+
++(void) dismissVisibleHintInView:(UIView*)view withType:(HintType)type
+{
+ for (UIView* subview in view.subviews )
+ {
+ if( [subview isKindOfClass:[TBHintView class]] )
+ {
+ TBHintView* hintView = (TBHintView*)subview;
+ if( hintView.type == type )
+ {
+ [hintView dismiss];
+ }
+ }
+ }
+}
+
+
+
@end

0 comments on commit 7b40b85

Please sign in to comment.