Skip to content

Commit

Permalink
no arrow implementation on demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvise Susmel committed Feb 11, 2013
1 parent 2da269f commit 1b7b8ee
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 9 deletions.
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions FPPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,19 @@ -(CGRect)bestViewFrameForFromPoint:(CGPoint)point

-(CGRect)bestArrowDirectionAndFrameFromView:(UIView*)v
{
CGPoint p = [v.superview convertPoint:v.frame.origin toView:self.view];
//thanks @Niculcea
// If we presentFromPoint with _fromView nil will calculate based on self.orgin with 2x2 size.
// Fix for presentFromPoint from avolovoy's FPPopover fork
float width = 2.0f;
float height = 2.0f;
CGPoint p = CGPointMake(self.origin.x, self.origin.y);

if (v != nil) {
p = [v.superview convertPoint:v.frame.origin toView:self.view];
width = v.frame.size.width;
height = v.frame.size.height;
}


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

//check if the developer wants and arror
//check if the developer wants and arrow
if(self.arrowDirection != FPPopoverNoArrow)
_contentView.arrowDirection = bestDirection;

Expand Down
4 changes: 4 additions & 0 deletions FPPopoverDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

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

/* Begin PBXFileReference section */
1851C5E916C972A000CCCDB3 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
186C436F1538512100502D64 /* FPPopoverDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FPPopoverDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
186C43731538512100502D64 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
186C43751538512100502D64 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -102,6 +104,7 @@
186C43641538512100502D64 = {
isa = PBXGroup;
children = (
1851C5E916C972A000CCCDB3 /* [email protected] */,
18D8FA4815505DFD005E2222 /* LICENSE */,
186C439A153851F600502D64 /* Readme.md */,
186C43931538512A00502D64 /* FPPopover */,
Expand Down Expand Up @@ -299,6 +302,7 @@
18EF6DEB154ED27D005AB1DD /* background.png in Resources */,
18EF6DEC154ED27D005AB1DD /* [email protected] in Resources */,
18D8FA45155051BA005E2222 /* background_iPad.png in Resources */,
1851C5EA16C972A000CCCDB3 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions FPPopoverDemo/FPDemoTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ - (void)viewDidLoad

}

- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewDidUnload
{
[super viewDidUnload];
Expand Down
4 changes: 4 additions & 0 deletions FPPopoverDemo/FPViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{
FPPopoverController *popover;
}
@property (weak, nonatomic) IBOutlet UIButton *noArrow;


-(IBAction)topLeft:(id)sender;
Expand All @@ -34,4 +35,7 @@
-(IBAction)goToTableView:(id)sender;

-(void)selectedTableRow:(NSUInteger)rowNum;

-(IBAction)noArrow:(id)sender;

@end
24 changes: 20 additions & 4 deletions FPPopoverDemo/FPViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ @interface FPViewController ()
@end

@implementation FPViewController
@synthesize noArrow = _noArrow;

- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setNavigationBarHidden:YES];


}

- (void)viewDidUnload
Expand Down Expand Up @@ -55,6 +58,7 @@ -(void)popover:(id)sender

popover.tint = FPPopoverDefaultTint;


if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
popover.contentSize = CGSizeMake(300, 500);
Expand All @@ -63,10 +67,22 @@ -(void)popover:(id)sender
popover.contentSize = CGSizeMake(200, 300);
}

popover.arrowDirection = FPPopoverArrowDirectionAny;

//sender is the UIButton view
[popover presentPopoverFromView:sender];
if(sender == _noArrow) {
//no arrow
popover.arrowDirection = FPPopoverNoArrow;
[popover presentPopoverFromPoint: CGPointMake(self.view.center.x, self.view.center.y - popover.contentSize.height/2)];
}
else {
//sender is the UIButton view
popover.arrowDirection = FPPopoverArrowDirectionAny;
[popover presentPopoverFromView:sender];
}

}

-(IBAction)noArrow:(id)sender
{
[self popover:sender];
}


Expand Down
84 changes: 82 additions & 2 deletions FPPopoverDemo/en.lproj/FPViewController_iPad.xib
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1536</int>
<string key="IBDocument.SystemVersion">12C60</string>
<string key="IBDocument.SystemVersion">12C3012</string>
<string key="IBDocument.InterfaceBuilderVersion">2840</string>
<string key="IBDocument.AppKitVersion">1187.34</string>
<string key="IBDocument.HIToolboxVersion">625.00</string>
Expand Down Expand Up @@ -41,6 +41,7 @@
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{768, 1004}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
Expand All @@ -54,6 +55,7 @@
<int key="NSvFlags">289</int>
<string key="NSFrame">{{679, 20}, {75, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="588936024"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand Down Expand Up @@ -89,6 +91,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 953}, {82, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="477294834"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -111,6 +114,7 @@
<int key="NSvFlags">257</int>
<string key="NSFrame">{{666, 486}, {82, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1004504562"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -133,6 +137,7 @@
<int key="NSvFlags">265</int>
<string key="NSFrame">{{656, 953}, {92, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
Expand All @@ -154,6 +159,7 @@
<int key="NSvFlags">264</int>
<string key="NSFrame">{{347, 953}, {92, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="627753422"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -176,6 +182,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 20}, {71, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="778322237"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -198,6 +205,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 248}, {44, 37}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="737730267"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand Down Expand Up @@ -227,6 +235,7 @@
<int key="NSvFlags">289</int>
<string key="NSFrame">{{704, 248}, {44, 37}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="923775962"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -249,6 +258,7 @@
<int key="NSvFlags">260</int>
<string key="NSFrame">{{20, 486}, {82, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="281061027"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -271,6 +281,7 @@
<int key="NSvFlags">256</int>
<string key="NSFrame">{{343, 486}, {82, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1045211851"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -293,6 +304,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{347, 20}, {75, 31}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="578823731"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -310,9 +322,32 @@
<reference key="IBUIFontDescription" ref="188992727"/>
<reference key="IBUIFont" ref="325292797"/>
</object>
<object class="IBUIButton" id="658571848">
<reference key="NSNextResponder" ref="766721923"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{338, 272}, {92, 44}}</string>
<reference key="NSSuperview" ref="766721923"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">No Arrow</string>
<reference key="IBUIHighlightedTitleColor" ref="88457527"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="1038930313"/>
<reference key="IBUIFontDescription" ref="320996488"/>
<reference key="IBUIFont" ref="915512786"/>
</object>
</array>
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="592710193"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
Expand All @@ -337,6 +372,14 @@
</object>
<int key="connectionID">3</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">noArrow</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="658571848"/>
</object>
<int key="connectionID">41</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">topRight:</string>
Expand Down Expand Up @@ -436,6 +479,15 @@
</object>
<int key="connectionID">28</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">noArrow:</string>
<reference key="source" ref="658571848"/>
<reference key="destination" ref="841351856"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">40</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand Down Expand Up @@ -472,6 +524,7 @@
<reference ref="1045211851"/>
<reference ref="1004504562"/>
<reference ref="578823731"/>
<reference ref="658571848"/>
</array>
<reference key="parent" ref="0"/>
</object>
Expand Down Expand Up @@ -535,6 +588,11 @@
<reference key="object" ref="778322237"/>
<reference key="parent" ref="766721923"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">39</int>
<reference key="object" ref="658571848"/>
<reference key="parent" ref="766721923"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -554,13 +612,14 @@
<string key="24.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="25.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="26.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="39.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">38</int>
<int key="maxID">41</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -571,10 +630,12 @@
<string key="bottomCenter:">id</string>
<string key="bottomLeft:">id</string>
<string key="bottomRight:">id</string>
<string key="goToTableView:">id</string>
<string key="lt:">id</string>
<string key="midCenter:">id</string>
<string key="midLeft:">id</string>
<string key="midRight:">id</string>
<string key="noArrow:">id</string>
<string key="rt:">id</string>
<string key="topCenter:">id</string>
<string key="topLeft:">id</string>
Expand All @@ -593,6 +654,10 @@
<string key="name">bottomRight:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="goToTableView:">
<string key="name">goToTableView:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="lt:">
<string key="name">lt:</string>
<string key="candidateClassName">id</string>
Expand All @@ -609,6 +674,10 @@
<string key="name">midRight:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="noArrow:">
<string key="name">noArrow:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="rt:">
<string key="name">rt:</string>
<string key="candidateClassName">id</string>
Expand All @@ -626,6 +695,17 @@
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">noArrow</string>
<string key="NS.object.0">UIButton</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">noArrow</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">noArrow</string>
<string key="candidateClassName">UIButton</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/FPViewController.h</string>
Expand Down
Loading

0 comments on commit 1b7b8ee

Please sign in to comment.