Skip to content

Commit d407488

Browse files
author
Stephan Heilner
committed
Added popoverContentSize property to match UIPopoverController behavior
1 parent dae198d commit d407488

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

WYPopoverController/WYPopoverController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverArrowDirection) {
8888
@property (nonatomic, assign) UIEdgeInsets popoverLayoutMargins;
8989
@property (nonatomic, assign, readonly) BOOL isPopoverVisible;
9090
@property (nonatomic, strong, readonly) UIViewController* contentViewController;
91+
@property (nonatomic, assign) CGSize popoverContentSize;
9192

9293
- (id)initWithContentViewController:(UIViewController *)viewController;
9394

WYPopoverController/WYPopoverController.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,40 @@ - (UIColor *)overlayColor
13381338
return result;
13391339
}
13401340

1341+
- (CGSize)popoverContentSize
1342+
{
1343+
if ([viewController respondsToSelector:@selector(preferredContentSize)])
1344+
{
1345+
return [viewController preferredContentSize];
1346+
}
1347+
else if ([viewController respondsToSelector:@selector(contentSizeForViewInPopover:)])
1348+
{
1349+
#pragma clang diagnostic push
1350+
#pragma GCC diagnostic ignored "-Wdeprecated"
1351+
return [viewController contentSizeForViewInPopover];
1352+
#pragma clang diagnostic pop
1353+
}
1354+
1355+
return CGSizeZero;
1356+
}
1357+
1358+
- (void)setPopoverContentSize:(CGSize)size
1359+
{
1360+
if ([viewController respondsToSelector:@selector(setPreferredContentSize:)])
1361+
{
1362+
[viewController setPreferredContentSize:size];
1363+
}
1364+
else if ([viewController respondsToSelector:@selector(setContentSizeForViewInPopover:)])
1365+
{
1366+
#pragma clang diagnostic push
1367+
#pragma GCC diagnostic ignored "-Wdeprecated"
1368+
[viewController setContentSizeForViewInPopover:size];
1369+
#pragma clang diagnostic pop
1370+
}
1371+
1372+
[self positionPopover];
1373+
}
1374+
13411375
- (CGSize)contentSizeForViewInPopover
13421376
{
13431377
CGSize result = CGSizeZero;

0 commit comments

Comments
 (0)