Permalink
Browse files

fix topwindow/topView problem, use PopoverView_Configuration definitions

  • Loading branch information...
1 parent 53d5c24 commit a3695c6a2cd38ce7ad1486a515033542f60e01c4 @gereons gereons committed Jan 14, 2013
View
20 PopoverView/PopoverView.m
@@ -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]]];
@@ -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]]];
@@ -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]];
@@ -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]];
@@ -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];
@@ -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;
@@ -1040,9 +1037,4 @@ - (void)drawRect:(CGRect)rect
}
}
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- return YES;
-}
-
@end
View
2 PopoverView/PopoverView_Configuration.h
@@ -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
View
5 popover/Demo/ViewController.m
@@ -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
View
4 popover/Demo/popover-Info.plist
@@ -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.