Skip to content

Commit

Permalink
fix topwindow/topView problem, use PopoverView_Configuration definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gereons committed Jan 14, 2013
1 parent 53d5c24 commit a3695c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
20 changes: 6 additions & 14 deletions PopoverView/PopoverView.m
Expand Up @@ -169,7 +169,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)te
[textView setNumberOfLines:0]; //This is so the label word wraps instead of cutting off the text
textView.font = font;
textView.textAlignment = kTextAlignment;
textView.textColor = [UIColor colorWithRed:0.329 green:0.341 blue:0.353 alpha:1];
textView.textColor = kTextColor;
textView.text = text;

[self showAtPoint:point inView:view withViewArray:[NSArray arrayWithObject:[textView autorelease]]];
Expand All @@ -188,7 +188,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t
[textView setNumberOfLines:0]; //This is so the label word wraps instead of cutting off the text
textView.font = font;
textView.textAlignment = kTextAlignment;
textView.textColor = [UIColor colorWithRed:0.329 green:0.341 blue:0.353 alpha:1];
textView.textColor = kTextColor;
textView.text = text;

[self showAtPoint:point inView:view withTitle:title withViewArray:[NSArray arrayWithObject:[textView autorelease]]];
Expand Down Expand Up @@ -365,7 +365,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withStringArray:(NSArra
[textButton setTitle:string forState:UIControlStateNormal];
textButton.layer.cornerRadius = 4.f;
[textButton setTitleColor:kTextColor forState:UIControlStateNormal];
[textButton setTitleColor:[UIColor colorWithRed:0.098 green:0.102 blue:0.106 alpha:1.000] forState:UIControlStateHighlighted];
[textButton setTitleColor:kTextHighlightColor forState:UIControlStateHighlighted];
[textButton addTarget:self action:@selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside];

[labelArray addObject:[textButton autorelease]];
Expand All @@ -390,7 +390,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t
[textButton setTitle:string forState:UIControlStateNormal];
textButton.layer.cornerRadius = 4.f;
[textButton setTitleColor:kTextColor forState:UIControlStateNormal];
[textButton setTitleColor:[UIColor colorWithRed:0.098 green:0.102 blue:0.106 alpha:1.000] forState:UIControlStateHighlighted];
[textButton setTitleColor:kTextHighlightColor forState:UIControlStateHighlighted];
[textButton addTarget:self action:@selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside];

[labelArray addObject:[textButton autorelease]];
Expand Down Expand Up @@ -480,10 +480,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withContentView:(UIView

// get the top view
// http://stackoverflow.com/questions/3843411/getting-reference-to-the-top-most-view-window-in-ios-application/8045804#8045804
UIWindow *topWindow = [[[UIApplication sharedApplication].windows sortedArrayUsingComparator:^NSComparisonResult(UIWindow *win1, UIWindow *win2) {
return win1.windowLevel - win2.windowLevel;
}] lastObject];
topView = [[topWindow subviews] lastObject];
topView = [[[[UIApplication sharedApplication] keyWindow] subviews] lastObject];

[self setupLayout:point inView:view];

Expand Down Expand Up @@ -921,7 +918,7 @@ - (void)drawRect:(CGRect)rect
CGContextRef context = UIGraphicsGetCurrentContext();

//// Shadow Declarations
UIColor* shadow = [UIColor colorWithRed:0.f green:0.f blue:0.f alpha:kShadowAlpha];
UIColor* shadow = [UIColor colorWithWhite:0.0f alpha:kShadowAlpha];
CGSize shadowOffset = CGSizeMake(0, 1);
CGFloat shadowBlurRadius = kShadowBlur;

Expand Down Expand Up @@ -1040,9 +1037,4 @@ - (void)drawRect:(CGRect)rect
}
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

@end
2 changes: 2 additions & 0 deletions PopoverView/PopoverView_Configuration.h
Expand Up @@ -87,6 +87,8 @@

//normal text color
#define kTextColor [UIColor colorWithRed:0.329 green:0.341 blue:0.353 alpha:1]
// highlighted text color
#define kTextHighlightColor [UIColor colorWithRed:0.098 green:0.102 blue:0.106 alpha:1.000]

//normal text alignment
#define kTextAlignment UITextAlignmentCenter
Expand Down
5 changes: 4 additions & 1 deletion popover/Demo/ViewController.m
Expand Up @@ -171,7 +171,10 @@ - (void)viewDidUnload

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
// or, depending on the app setup, one of
// return UIInterfaceOrientationIsPortrait(interfaceOrientation);
// return YES;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
Expand Down
4 changes: 0 additions & 4 deletions popover/Demo/popover-Info.plist
Expand Up @@ -34,17 +34,13 @@
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>

0 comments on commit a3695c6

Please sign in to comment.