Skip to content

Commit 913b950

Browse files
fix issue #15
1 parent 22fef88 commit 913b950

7 files changed

Lines changed: 118 additions & 41 deletions

File tree

WYPopoverController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ Pod::Spec.new do |s|
1212
s.platform = :ios, '5.0'
1313
s.source_files = 'WYPopoverController/*.{h,m}'
1414
s.requires_arc = true
15-
s.frameworks = 'QuartzCore', 'UIKit'
15+
s.frameworks = 'QuartzCore', 'UIKit', 'CoreGraphics'
1616
end

WYPopoverController/WYPopoverController.m

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,13 +1306,20 @@ - (void)presentPopoverFromRect:(CGRect)aRect inView:(UIView *)aView permittedArr
13061306
[UIView animateWithDuration:WYPOPOVER_DEFAULT_ANIMATION_DURATION animations:^{
13071307
containerView.alpha = 1;
13081308
} completion:^(BOOL finished) {
1309-
[viewController viewDidAppear:YES];
1309+
if ([viewController isKindOfClass:[UINavigationController class]] == NO)
1310+
{
1311+
[viewController viewDidAppear:YES];
1312+
}
13101313
}];
13111314
}
13121315
else
13131316
{
13141317
[viewController viewWillAppear:NO];
1315-
[viewController viewDidAppear:NO];
1318+
1319+
if ([viewController isKindOfClass:[UINavigationController class]] == NO)
1320+
{
1321+
[viewController viewDidAppear:YES];
1322+
}
13161323
}
13171324

13181325
if (isListeningNotifications == NO)
@@ -1603,7 +1610,10 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate
16031610

16041611
[overlayView removeFromSuperview];
16051612

1606-
[viewController viewDidDisappear:aAnimated];
1613+
if ([viewController isKindOfClass:[UINavigationController class]] == NO)
1614+
{
1615+
[viewController viewDidDisappear:aAnimated];
1616+
}
16071617

16081618
if (callDelegate)
16091619
{
@@ -1636,7 +1646,10 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate
16361646

16371647
if (aAnimated)
16381648
{
1639-
[viewController viewWillDisappear:YES];
1649+
if ([viewController isKindOfClass:[UINavigationController class]] == NO)
1650+
{
1651+
[viewController viewWillDisappear:aAnimated];
1652+
}
16401653

16411654
[UIView animateWithDuration:WYPOPOVER_DEFAULT_ANIMATION_DURATION animations:^{
16421655
containerView.alpha = 0;
@@ -1646,7 +1659,10 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated callDelegate:(BOOL)callDelegate
16461659
}
16471660
else
16481661
{
1649-
[viewController viewWillDisappear:NO];
1662+
if ([viewController isKindOfClass:[UINavigationController class]] == NO)
1663+
{
1664+
[viewController viewWillDisappear:NO];
1665+
}
16501666
completionBlock(YES);
16511667
}
16521668
}

demos/Demo/WYPopoverDemo/WYAllDirectionsViewController.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ - (IBAction)tapOnButton:(id)sender
5959
settingsViewController.title = @"PDF Settings";
6060
[settingsViewController.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]];
6161

62-
UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
63-
64-
UIViewController* contentViewController = navigationController;
62+
UINavigationController* contentViewController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
6563

6664
popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
6765
popoverController.delegate = self;

demos/Demo/WYPopoverDemo/WYAppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2222
WYPopoverBackgroundView* popoverAppearance = [WYPopoverBackgroundView appearance];
2323
[popoverAppearance setTintColor:[UIColor whiteColor]];
2424

25-
[popoverAppearance setOuterCornerRadius:20];
25+
[popoverAppearance setOuterCornerRadius:8];
2626
[popoverAppearance setOuterShadowBlurRadius:6];
2727
[popoverAppearance setOuterShadowColor:[UIColor colorWithWhite:0 alpha:0.65]];
2828
[popoverAppearance setOuterShadowOffset:CGSizeMake(0, 2)];

demos/Demo/WYPopoverDemo/WYSettingsViewController.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ - (void)viewDidLoad
2626
//[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"WYSettingsTableViewCell"];
2727
}
2828

29+
- (void)viewWillAppear:(BOOL)animated
30+
{
31+
NSLog(@"view WILL appear");
32+
}
33+
34+
- (void)viewDidAppear:(BOOL)animated
35+
{
36+
NSLog(@"view DID appear");
37+
}
38+
39+
- (void)viewWillDisappear:(BOOL)animated
40+
{
41+
NSLog(@"view WILL disappear");
42+
}
43+
44+
- (void)viewDidDisappear:(BOOL)animated
45+
{
46+
NSLog(@"view DID disappear");
47+
}
48+
2949
- (void)didReceiveMemoryWarning
3050
{
3151
[super didReceiveMemoryWarning];

demos/DemoSegue/WYPopoverDemoSegue/WYGesturesViewController.m

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "WYGesturesViewController.h"
1010
#import "WYPopoverController.h"
11-
#import "WYTestViewController.h"
1211

1312
@interface WYGesturesViewController () <WYPopoverControllerDelegate>
1413
{
@@ -19,46 +18,21 @@ @interface WYGesturesViewController () <WYPopoverControllerDelegate>
1918

2019
@implementation WYGesturesViewController
2120

22-
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
23-
{
24-
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
25-
if (self) {
26-
// Custom initialization
27-
}
28-
return self;
29-
}
30-
3121
- (IBAction)buttonTap:(id)sender
3222
{
33-
UIView* view = (UIView*)sender;
23+
UIView* view = (UIView *)sender;
3424

35-
WYTestViewController* contentViewController = [[WYTestViewController alloc] init];
36-
contentViewController.contentSizeForViewInPopover = CGSizeMake(200, 200);
25+
UINavigationController* contentViewController = [[UINavigationController alloc] initWithRootViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"StadiumList"]];
3726

3827
popoverController = [[WYPopoverController alloc] initWithContentViewController:contentViewController];
3928
popoverController.delegate = self;
4029

41-
[((WYPopoverController *)popoverController) presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:WYPopoverArrowDirectionRight animated:YES];
42-
}
43-
44-
- (void)viewDidLoad
45-
{
46-
[super viewDidLoad];
47-
// Do any additional setup after loading the view.
30+
[popoverController presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:WYPopoverArrowDirectionAny animated:YES];
4831
}
4932

50-
- (void)didReceiveMemoryWarning
51-
{
52-
[super didReceiveMemoryWarning];
53-
// Dispose of any resources that can be recreated.
54-
}
55-
56-
#pragma mark - WYPopoverControllerDelegate
57-
5833
- (BOOL)popoverControllerShouldDismiss:(WYPopoverController *)aPopoverController
5934
{
6035
return YES;
6136
}
6237

63-
6438
@end

demos/DemoSegue/WYPopoverDemoSegue/en.lproj/MainStoryboard.storyboard

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,75 @@
44
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
55
</dependencies>
66
<scenes>
7+
<!--Table View Controller-->
8+
<scene sceneID="bjB-Hg-fD8">
9+
<objects>
10+
<tableViewController storyboardIdentifier="StadiumList" id="gbr-lX-aG6" sceneMemberID="viewController">
11+
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="lZo-AP-iec">
12+
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
13+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
14+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
15+
<sections>
16+
<tableViewSection id="8xn-Tk-JuH">
17+
<cells>
18+
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="StadiumCell" textLabel="PIj-mm-nfO" style="IBUITableViewCellStyleDefault" id="cb1-Qg-z15">
19+
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
20+
<autoresizingMask key="autoresizingMask"/>
21+
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
22+
<rect key="frame" x="0.0" y="0.0" width="300" height="43"/>
23+
<autoresizingMask key="autoresizingMask"/>
24+
<subviews>
25+
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="My stadium" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="PIj-mm-nfO">
26+
<rect key="frame" x="10" y="0.0" width="280" height="43"/>
27+
<autoresizingMask key="autoresizingMask"/>
28+
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
29+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
30+
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
31+
</label>
32+
</subviews>
33+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
34+
</view>
35+
<connections>
36+
<segue destination="M3Q-T3-fXm" kind="push" identifier="ViewStadiumSegue" id="sh8-Vm-rzw"/>
37+
</connections>
38+
</tableViewCell>
39+
</cells>
40+
</tableViewSection>
41+
</sections>
42+
<connections>
43+
<outlet property="dataSource" destination="gbr-lX-aG6" id="Y1s-ef-1qP"/>
44+
<outlet property="delegate" destination="gbr-lX-aG6" id="4ix-0w-QOe"/>
45+
</connections>
46+
</tableView>
47+
</tableViewController>
48+
<placeholder placeholderIdentifier="IBFirstResponder" id="LYb-Kj-Ehd" userLabel="First Responder" sceneMemberID="firstResponder"/>
49+
</objects>
50+
<point key="canvasLocation" x="970" y="1084"/>
51+
</scene>
52+
<!--View Controller-->
53+
<scene sceneID="K9Q-Us-0ot">
54+
<objects>
55+
<viewController id="M3Q-T3-fXm" sceneMemberID="viewController">
56+
<view key="view" contentMode="scaleToFill" id="lja-Vf-8yy">
57+
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
58+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
59+
<subviews>
60+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Stadium" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="eja-GI-8JD">
61+
<rect key="frame" x="20" y="20" width="280" height="21"/>
62+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
63+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
64+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
65+
<nil key="highlightedColor"/>
66+
</label>
67+
</subviews>
68+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
69+
</view>
70+
<navigationItem key="navigationItem" id="nXI-Mk-Si2"/>
71+
</viewController>
72+
<placeholder placeholderIdentifier="IBFirstResponder" id="ald-mK-bvT" userLabel="First Responder" sceneMemberID="firstResponder"/>
73+
</objects>
74+
<point key="canvasLocation" x="1505" y="1084"/>
75+
</scene>
776
<!--Gestures View Controller - Gestures-->
877
<scene sceneID="z3D-ex-Vu7">
978
<objects>
@@ -13,7 +82,7 @@
1382
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1483
<subviews>
1584
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="IkW-kR-gBw">
16-
<rect key="frame" x="216" y="121" width="84" height="44"/>
85+
<rect key="frame" x="20" y="20" width="84" height="44"/>
1786
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1887
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
1988
<state key="normal" title="popover">
@@ -34,7 +103,7 @@
34103
</viewController>
35104
<placeholder placeholderIdentifier="IBFirstResponder" id="NoG-nP-mTO" userLabel="First Responder" sceneMemberID="firstResponder"/>
36105
</objects>
37-
<point key="canvasLocation" x="970" y="396"/>
106+
<point key="canvasLocation" x="970" y="384"/>
38107
</scene>
39108
<!--Tab Bar Controller-->
40109
<scene sceneID="p9h-m5-ce2">

0 commit comments

Comments
 (0)