@@ -46,7 +46,6 @@ @interface WYPopoverArea : NSObject
4646
4747@property (nonatomic , assign ) WYPopoverArrowDirection arrowDirection;
4848@property (nonatomic , assign ) CGSize areaSize;
49- @property (nonatomic , assign , readonly ) NSUInteger priority;
5049@property (nonatomic , assign , readonly ) CGFloat value;
5150
5251@end
@@ -60,7 +59,6 @@ @implementation WYPopoverArea
6059
6160@synthesize arrowDirection;
6261@synthesize areaSize;
63- @synthesize priority;
6462@synthesize value;
6563
6664- (NSString *)description
@@ -87,30 +85,6 @@ - (NSString*)description
8785 return [NSString stringWithFormat: @" %@ [ %f x %f ]" , direction, areaSize.width, areaSize.height];
8886}
8987
90- - (NSUInteger )priority
91- {
92- NSUInteger result = 0 ;
93-
94- if (arrowDirection == WYPopoverArrowDirectionRight)
95- {
96- result = 1 ;
97- }
98- else if (arrowDirection == WYPopoverArrowDirectionLeft)
99- {
100- result = 2 ;
101- }
102- else if (arrowDirection == WYPopoverArrowDirectionUp)
103- {
104- result = 3 ;
105- }
106- else if (arrowDirection == WYPopoverArrowDirectionDown)
107- {
108- result = 4 ;
109- }
110-
111- return result;
112- }
113-
11488- (CGFloat)value
11589{
11690 CGFloat result = 0 ;
@@ -943,7 +917,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
943917
944918 CGPoint origin = CGPointZero;
945919
946- CGFloat reducedOuterCornerRadius = outerCornerRadius ;
920+ CGFloat reducedOuterCornerRadius = 0 ;
947921
948922 if (arrowDirection == WYPopoverArrowDirectionUp || arrowDirection == WYPopoverArrowDirectionDown)
949923 {
@@ -1340,19 +1314,21 @@ - (UIColor *)overlayColor
13401314
13411315- (CGSize)popoverContentSize
13421316{
1317+ CGSize result = CGSizeZero;
1318+
13431319 if ([viewController respondsToSelector: @selector (preferredContentSize )])
13441320 {
1345- return [viewController preferredContentSize ];
1321+ result = [viewController preferredContentSize ];
13461322 }
1347- else if ([viewController respondsToSelector: @selector ( contentSizeForViewInPopover: )])
1323+ else
13481324 {
13491325#pragma clang diagnostic push
13501326#pragma GCC diagnostic ignored "-Wdeprecated"
1351- return [viewController contentSizeForViewInPopover ];
1327+ result = [viewController contentSizeForViewInPopover ];
13521328#pragma clang diagnostic pop
13531329 }
13541330
1355- return CGSizeZero ;
1331+ return result ;
13561332}
13571333
13581334- (void )setPopoverContentSize : (CGSize)size
@@ -1361,7 +1337,7 @@ - (void)setPopoverContentSize:(CGSize)size
13611337 {
13621338 [viewController setPreferredContentSize: size];
13631339 }
1364- else if ([viewController respondsToSelector: @selector ( setContentSizeForViewInPopover: )])
1340+ else
13651341 {
13661342#pragma clang diagnostic push
13671343#pragma GCC diagnostic ignored "-Wdeprecated"
@@ -2037,7 +2013,29 @@ - (WYPopoverArrowDirection)arrowDirectionForRect:(CGRect)aRect
20372013
20382014 if (arrowDirection == WYPopoverArrowDirectionUnknown)
20392015 {
2040- arrowDirection = ((WYPopoverArea*)[areas objectAtIndex: 0 ]).arrowDirection ;
2016+ if ([areas count ] > 0 )
2017+ {
2018+ arrowDirection = ((WYPopoverArea*)[areas objectAtIndex: 0 ]).arrowDirection ;
2019+ }
2020+ else
2021+ {
2022+ if ((arrowDirections & WYPopoverArrowDirectionDown) == WYPopoverArrowDirectionDown)
2023+ {
2024+ arrowDirection = WYPopoverArrowDirectionDown;
2025+ }
2026+ else if ((arrowDirections & WYPopoverArrowDirectionUp) == WYPopoverArrowDirectionUp)
2027+ {
2028+ arrowDirection = WYPopoverArrowDirectionUp;
2029+ }
2030+ else if ((arrowDirections & WYPopoverArrowDirectionLeft) == WYPopoverArrowDirectionLeft)
2031+ {
2032+ arrowDirection = WYPopoverArrowDirectionLeft;
2033+ }
2034+ else
2035+ {
2036+ arrowDirection = WYPopoverArrowDirectionRight;
2037+ }
2038+ }
20412039 }
20422040
20432041 return arrowDirection;
0 commit comments