Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions WYPopoverController/WYPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ + (void)load {
swizzle = class_getInstanceMethod(self, @selector(sizzled_setViewControllers:animated:));

method_exchangeImplementations(original, swizzle);

original = class_getInstanceMethod(self, @selector(popViewControllerAnimated:));
swizzle = class_getInstanceMethod(self, @selector(sizzled_popViewControllerAnimated:));

method_exchangeImplementations(original, swizzle);
}

- (BOOL)wy_isEmbedInPopover {
Expand Down Expand Up @@ -268,6 +273,34 @@ - (void)sizzled_pushViewController:(UIViewController *)aViewController animated:
}
}

-(void)sizzled_popViewControllerAnimated:(BOOL)animated
{
if(self.viewControllers.count <= 1)
{
//Let the system handle the special case
[self sizzled_popViewControllerAnimated:animated];
return;
}

UIViewController *vc = [self.viewControllers objectAtIndex:self.viewControllers.count - 2];
if (self.wy_isEmbedInPopover) {
#ifdef WY_BASE_SDK_7_ENABLED
if ([vc respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
vc.edgesForExtendedLayout = UIRectEdgeNone;
}
#endif
CGSize contentSize = [self contentSize:vc];
[self setContentSize:contentSize];
}

[self sizzled_popViewControllerAnimated:animated];

if (self.wy_isEmbedInPopover) {
CGSize contentSize = [self contentSize:vc];
[self setContentSize:contentSize];
}
}

- (void)sizzled_setViewControllers:(NSArray *)aViewControllers animated:(BOOL)aAnimated {
NSUInteger count = [aViewControllers count];

Expand Down