Skip to content

Commit 1b7b8ee

Browse files
author
Alvise Susmel
committed
no arrow implementation on demo
1 parent 2da269f commit 1b7b8ee

File tree

9 files changed

+193
-9
lines changed

9 files changed

+193
-9
lines changed

[email protected]

18.2 KB
Loading

FPPopoverController.m

+14-2
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,19 @@ -(CGRect)bestViewFrameForFromPoint:(CGPoint)point
457457

458458
-(CGRect)bestArrowDirectionAndFrameFromView:(UIView*)v
459459
{
460-
CGPoint p = [v.superview convertPoint:v.frame.origin toView:self.view];
460+
//thanks @Niculcea
461+
// If we presentFromPoint with _fromView nil will calculate based on self.orgin with 2x2 size.
462+
// Fix for presentFromPoint from avolovoy's FPPopover fork
463+
float width = 2.0f;
464+
float height = 2.0f;
465+
CGPoint p = CGPointMake(self.origin.x, self.origin.y);
466+
467+
if (v != nil) {
468+
p = [v.superview convertPoint:v.frame.origin toView:self.view];
469+
width = v.frame.size.width;
470+
height = v.frame.size.height;
471+
}
472+
461473

462474
CGFloat ht = p.y; //available vertical space on top of the view
463475
CGFloat hb = [self parentHeight] - (p.y + v.frame.size.height); //on the bottom
@@ -564,7 +576,7 @@ -(CGRect)bestArrowDirectionAndFrameFromView:(UIView*)v
564576
if(r.origin.y <= 20) r.origin.y += 20;
565577
}
566578

567-
//check if the developer wants and arror
579+
//check if the developer wants and arrow
568580
if(self.arrowDirection != FPPopoverNoArrow)
569581
_contentView.arrowDirection = bestDirection;
570582

FPPopoverDemo.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
1851C5EA16C972A000CCCDB3 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1851C5E916C972A000CCCDB3 /* [email protected] */; };
1011
186C43741538512100502D64 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43731538512100502D64 /* UIKit.framework */; };
1112
186C43761538512100502D64 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43751538512100502D64 /* Foundation.framework */; };
1213
186C43781538512100502D64 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 186C43771538512100502D64 /* CoreGraphics.framework */; };
@@ -43,6 +44,7 @@
4344
/* End PBXContainerItemProxy section */
4445

4546
/* Begin PBXFileReference section */
47+
1851C5E916C972A000CCCDB3 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
4648
186C436F1538512100502D64 /* FPPopoverDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FPPopoverDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
4749
186C43731538512100502D64 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4850
186C43751538512100502D64 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -102,6 +104,7 @@
102104
186C43641538512100502D64 = {
103105
isa = PBXGroup;
104106
children = (
107+
1851C5E916C972A000CCCDB3 /* [email protected] */,
105108
18D8FA4815505DFD005E2222 /* LICENSE */,
106109
186C439A153851F600502D64 /* Readme.md */,
107110
186C43931538512A00502D64 /* FPPopover */,
@@ -299,6 +302,7 @@
299302
18EF6DEB154ED27D005AB1DD /* background.png in Resources */,
300303
18EF6DEC154ED27D005AB1DD /* [email protected] in Resources */,
301304
18D8FA45155051BA005E2222 /* background_iPad.png in Resources */,
305+
1851C5EA16C972A000CCCDB3 /* [email protected] in Resources */,
302306
);
303307
runOnlyForDeploymentPostprocessing = 0;
304308
};

FPPopoverDemo/FPDemoTableViewController.m

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ - (void)viewDidLoad
3535

3636
}
3737

38+
- (void) viewWillDisappear:(BOOL)animated
39+
{
40+
[super viewWillDisappear:animated];
41+
[self.navigationController setNavigationBarHidden:YES animated:YES];
42+
}
43+
3844
- (void)viewDidUnload
3945
{
4046
[super viewDidUnload];

FPPopoverDemo/FPViewController.h

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{
1414
FPPopoverController *popover;
1515
}
16+
@property (weak, nonatomic) IBOutlet UIButton *noArrow;
1617

1718

1819
-(IBAction)topLeft:(id)sender;
@@ -34,4 +35,7 @@
3435
-(IBAction)goToTableView:(id)sender;
3536

3637
-(void)selectedTableRow:(NSUInteger)rowNum;
38+
39+
-(IBAction)noArrow:(id)sender;
40+
3741
@end

FPPopoverDemo/FPViewController.m

+20-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ @interface FPViewController ()
1616
@end
1717

1818
@implementation FPViewController
19+
@synthesize noArrow = _noArrow;
1920

2021
- (void)viewDidLoad
2122
{
2223
[super viewDidLoad];
2324
[self.navigationController setNavigationBarHidden:YES];
25+
26+
2427
}
2528

2629
- (void)viewDidUnload
@@ -55,6 +58,7 @@ -(void)popover:(id)sender
5558

5659
popover.tint = FPPopoverDefaultTint;
5760

61+
5862
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
5963
{
6064
popover.contentSize = CGSizeMake(300, 500);
@@ -63,10 +67,22 @@ -(void)popover:(id)sender
6367
popover.contentSize = CGSizeMake(200, 300);
6468
}
6569

66-
popover.arrowDirection = FPPopoverArrowDirectionAny;
67-
68-
//sender is the UIButton view
69-
[popover presentPopoverFromView:sender];
70+
if(sender == _noArrow) {
71+
//no arrow
72+
popover.arrowDirection = FPPopoverNoArrow;
73+
[popover presentPopoverFromPoint: CGPointMake(self.view.center.x, self.view.center.y - popover.contentSize.height/2)];
74+
}
75+
else {
76+
//sender is the UIButton view
77+
popover.arrowDirection = FPPopoverArrowDirectionAny;
78+
[popover presentPopoverFromView:sender];
79+
}
80+
81+
}
82+
83+
-(IBAction)noArrow:(id)sender
84+
{
85+
[self popover:sender];
7086
}
7187

7288

FPPopoverDemo/en.lproj/FPViewController_iPad.xib

+82-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
33
<data>
44
<int key="IBDocument.SystemTarget">1536</int>
5-
<string key="IBDocument.SystemVersion">12C60</string>
5+
<string key="IBDocument.SystemVersion">12C3012</string>
66
<string key="IBDocument.InterfaceBuilderVersion">2840</string>
77
<string key="IBDocument.AppKitVersion">1187.34</string>
88
<string key="IBDocument.HIToolboxVersion">625.00</string>
@@ -41,6 +41,7 @@
4141
<int key="NSvFlags">274</int>
4242
<string key="NSFrameSize">{768, 1004}</string>
4343
<reference key="NSSuperview" ref="766721923"/>
44+
<reference key="NSWindow"/>
4445
<string key="NSReuseIdentifierKey">_NS:9</string>
4546
<bool key="IBUIUserInteractionEnabled">NO</bool>
4647
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -54,6 +55,7 @@
5455
<int key="NSvFlags">289</int>
5556
<string key="NSFrame">{{679, 20}, {75, 31}}</string>
5657
<reference key="NSSuperview" ref="766721923"/>
58+
<reference key="NSWindow"/>
5759
<reference key="NSNextKeyView" ref="588936024"/>
5860
<string key="NSReuseIdentifierKey">_NS:9</string>
5961
<bool key="IBUIOpaque">NO</bool>
@@ -89,6 +91,7 @@
8991
<int key="NSvFlags">268</int>
9092
<string key="NSFrame">{{20, 953}, {82, 31}}</string>
9193
<reference key="NSSuperview" ref="766721923"/>
94+
<reference key="NSWindow"/>
9295
<reference key="NSNextKeyView" ref="477294834"/>
9396
<string key="NSReuseIdentifierKey">_NS:9</string>
9497
<bool key="IBUIOpaque">NO</bool>
@@ -111,6 +114,7 @@
111114
<int key="NSvFlags">257</int>
112115
<string key="NSFrame">{{666, 486}, {82, 31}}</string>
113116
<reference key="NSSuperview" ref="766721923"/>
117+
<reference key="NSWindow"/>
114118
<reference key="NSNextKeyView" ref="1004504562"/>
115119
<string key="NSReuseIdentifierKey">_NS:9</string>
116120
<bool key="IBUIOpaque">NO</bool>
@@ -133,6 +137,7 @@
133137
<int key="NSvFlags">265</int>
134138
<string key="NSFrame">{{656, 953}, {92, 31}}</string>
135139
<reference key="NSSuperview" ref="766721923"/>
140+
<reference key="NSWindow"/>
136141
<string key="NSReuseIdentifierKey">_NS:9</string>
137142
<bool key="IBUIOpaque">NO</bool>
138143
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
@@ -154,6 +159,7 @@
154159
<int key="NSvFlags">264</int>
155160
<string key="NSFrame">{{347, 953}, {92, 31}}</string>
156161
<reference key="NSSuperview" ref="766721923"/>
162+
<reference key="NSWindow"/>
157163
<reference key="NSNextKeyView" ref="627753422"/>
158164
<string key="NSReuseIdentifierKey">_NS:9</string>
159165
<bool key="IBUIOpaque">NO</bool>
@@ -176,6 +182,7 @@
176182
<int key="NSvFlags">292</int>
177183
<string key="NSFrame">{{20, 20}, {71, 31}}</string>
178184
<reference key="NSSuperview" ref="766721923"/>
185+
<reference key="NSWindow"/>
179186
<reference key="NSNextKeyView" ref="778322237"/>
180187
<string key="NSReuseIdentifierKey">_NS:9</string>
181188
<bool key="IBUIOpaque">NO</bool>
@@ -198,6 +205,7 @@
198205
<int key="NSvFlags">292</int>
199206
<string key="NSFrame">{{20, 248}, {44, 37}}</string>
200207
<reference key="NSSuperview" ref="766721923"/>
208+
<reference key="NSWindow"/>
201209
<reference key="NSNextKeyView" ref="737730267"/>
202210
<string key="NSReuseIdentifierKey">_NS:9</string>
203211
<bool key="IBUIOpaque">NO</bool>
@@ -227,6 +235,7 @@
227235
<int key="NSvFlags">289</int>
228236
<string key="NSFrame">{{704, 248}, {44, 37}}</string>
229237
<reference key="NSSuperview" ref="766721923"/>
238+
<reference key="NSWindow"/>
230239
<reference key="NSNextKeyView" ref="923775962"/>
231240
<string key="NSReuseIdentifierKey">_NS:9</string>
232241
<bool key="IBUIOpaque">NO</bool>
@@ -249,6 +258,7 @@
249258
<int key="NSvFlags">260</int>
250259
<string key="NSFrame">{{20, 486}, {82, 31}}</string>
251260
<reference key="NSSuperview" ref="766721923"/>
261+
<reference key="NSWindow"/>
252262
<reference key="NSNextKeyView" ref="281061027"/>
253263
<string key="NSReuseIdentifierKey">_NS:9</string>
254264
<bool key="IBUIOpaque">NO</bool>
@@ -271,6 +281,7 @@
271281
<int key="NSvFlags">256</int>
272282
<string key="NSFrame">{{343, 486}, {82, 31}}</string>
273283
<reference key="NSSuperview" ref="766721923"/>
284+
<reference key="NSWindow"/>
274285
<reference key="NSNextKeyView" ref="1045211851"/>
275286
<string key="NSReuseIdentifierKey">_NS:9</string>
276287
<bool key="IBUIOpaque">NO</bool>
@@ -293,6 +304,7 @@
293304
<int key="NSvFlags">293</int>
294305
<string key="NSFrame">{{347, 20}, {75, 31}}</string>
295306
<reference key="NSSuperview" ref="766721923"/>
307+
<reference key="NSWindow"/>
296308
<reference key="NSNextKeyView" ref="578823731"/>
297309
<string key="NSReuseIdentifierKey">_NS:9</string>
298310
<bool key="IBUIOpaque">NO</bool>
@@ -310,9 +322,32 @@
310322
<reference key="IBUIFontDescription" ref="188992727"/>
311323
<reference key="IBUIFont" ref="325292797"/>
312324
</object>
325+
<object class="IBUIButton" id="658571848">
326+
<reference key="NSNextResponder" ref="766721923"/>
327+
<int key="NSvFlags">292</int>
328+
<string key="NSFrame">{{338, 272}, {92, 44}}</string>
329+
<reference key="NSSuperview" ref="766721923"/>
330+
<reference key="NSWindow"/>
331+
<string key="NSReuseIdentifierKey">_NS:9</string>
332+
<bool key="IBUIOpaque">NO</bool>
333+
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
334+
<int key="IBUIContentHorizontalAlignment">0</int>
335+
<int key="IBUIContentVerticalAlignment">0</int>
336+
<int key="IBUIButtonType">1</int>
337+
<string key="IBUINormalTitle">No Arrow</string>
338+
<reference key="IBUIHighlightedTitleColor" ref="88457527"/>
339+
<object class="NSColor" key="IBUINormalTitleColor">
340+
<int key="NSColorSpace">1</int>
341+
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
342+
</object>
343+
<reference key="IBUINormalTitleShadowColor" ref="1038930313"/>
344+
<reference key="IBUIFontDescription" ref="320996488"/>
345+
<reference key="IBUIFont" ref="915512786"/>
346+
</object>
313347
</array>
314348
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
315349
<reference key="NSSuperview"/>
350+
<reference key="NSWindow"/>
316351
<reference key="NSNextKeyView" ref="592710193"/>
317352
<object class="NSColor" key="IBUIBackgroundColor">
318353
<int key="NSColorSpace">3</int>
@@ -337,6 +372,14 @@
337372
</object>
338373
<int key="connectionID">3</int>
339374
</object>
375+
<object class="IBConnectionRecord">
376+
<object class="IBCocoaTouchOutletConnection" key="connection">
377+
<string key="label">noArrow</string>
378+
<reference key="source" ref="841351856"/>
379+
<reference key="destination" ref="658571848"/>
380+
</object>
381+
<int key="connectionID">41</int>
382+
</object>
340383
<object class="IBConnectionRecord">
341384
<object class="IBCocoaTouchEventConnection" key="connection">
342385
<string key="label">topRight:</string>
@@ -436,6 +479,15 @@
436479
</object>
437480
<int key="connectionID">28</int>
438481
</object>
482+
<object class="IBConnectionRecord">
483+
<object class="IBCocoaTouchEventConnection" key="connection">
484+
<string key="label">noArrow:</string>
485+
<reference key="source" ref="658571848"/>
486+
<reference key="destination" ref="841351856"/>
487+
<int key="IBEventType">7</int>
488+
</object>
489+
<int key="connectionID">40</int>
490+
</object>
439491
</array>
440492
<object class="IBMutableOrderedSet" key="objectRecords">
441493
<array key="orderedObjects">
@@ -472,6 +524,7 @@
472524
<reference ref="1045211851"/>
473525
<reference ref="1004504562"/>
474526
<reference ref="578823731"/>
527+
<reference ref="658571848"/>
475528
</array>
476529
<reference key="parent" ref="0"/>
477530
</object>
@@ -535,6 +588,11 @@
535588
<reference key="object" ref="778322237"/>
536589
<reference key="parent" ref="766721923"/>
537590
</object>
591+
<object class="IBObjectRecord">
592+
<int key="objectID">39</int>
593+
<reference key="object" ref="658571848"/>
594+
<reference key="parent" ref="766721923"/>
595+
</object>
538596
</array>
539597
</object>
540598
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -554,13 +612,14 @@
554612
<string key="24.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
555613
<string key="25.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
556614
<string key="26.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
615+
<string key="39.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
557616
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
558617
</dictionary>
559618
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
560619
<nil key="activeLocalization"/>
561620
<dictionary class="NSMutableDictionary" key="localizations"/>
562621
<nil key="sourceID"/>
563-
<int key="maxID">38</int>
622+
<int key="maxID">41</int>
564623
</object>
565624
<object class="IBClassDescriber" key="IBDocument.Classes">
566625
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -571,10 +630,12 @@
571630
<string key="bottomCenter:">id</string>
572631
<string key="bottomLeft:">id</string>
573632
<string key="bottomRight:">id</string>
633+
<string key="goToTableView:">id</string>
574634
<string key="lt:">id</string>
575635
<string key="midCenter:">id</string>
576636
<string key="midLeft:">id</string>
577637
<string key="midRight:">id</string>
638+
<string key="noArrow:">id</string>
578639
<string key="rt:">id</string>
579640
<string key="topCenter:">id</string>
580641
<string key="topLeft:">id</string>
@@ -593,6 +654,10 @@
593654
<string key="name">bottomRight:</string>
594655
<string key="candidateClassName">id</string>
595656
</object>
657+
<object class="IBActionInfo" key="goToTableView:">
658+
<string key="name">goToTableView:</string>
659+
<string key="candidateClassName">id</string>
660+
</object>
596661
<object class="IBActionInfo" key="lt:">
597662
<string key="name">lt:</string>
598663
<string key="candidateClassName">id</string>
@@ -609,6 +674,10 @@
609674
<string key="name">midRight:</string>
610675
<string key="candidateClassName">id</string>
611676
</object>
677+
<object class="IBActionInfo" key="noArrow:">
678+
<string key="name">noArrow:</string>
679+
<string key="candidateClassName">id</string>
680+
</object>
612681
<object class="IBActionInfo" key="rt:">
613682
<string key="name">rt:</string>
614683
<string key="candidateClassName">id</string>
@@ -626,6 +695,17 @@
626695
<string key="candidateClassName">id</string>
627696
</object>
628697
</dictionary>
698+
<object class="NSMutableDictionary" key="outlets">
699+
<string key="NS.key.0">noArrow</string>
700+
<string key="NS.object.0">UIButton</string>
701+
</object>
702+
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
703+
<string key="NS.key.0">noArrow</string>
704+
<object class="IBToOneOutletInfo" key="NS.object.0">
705+
<string key="name">noArrow</string>
706+
<string key="candidateClassName">UIButton</string>
707+
</object>
708+
</object>
629709
<object class="IBClassDescriptionSource" key="sourceIdentifier">
630710
<string key="majorKey">IBProjectSource</string>
631711
<string key="minorKey">./Classes/FPViewController.h</string>

0 commit comments

Comments
 (0)