mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Swapping WYPopoverController for old-looking WEPopover.
This commit is contained in:
parent
f837c45a50
commit
caf80431f5
16 changed files with 42 additions and 1294 deletions
|
@ -11,7 +11,7 @@
|
|||
#import "ASIHTTPRequest.h"
|
||||
#import "BaseViewController.h"
|
||||
#import "Utilities.h"
|
||||
#import "WEPopoverController.h"
|
||||
#import "WYPopoverController.h"
|
||||
#import "NBNotifier.h"
|
||||
#import "MCSwipeTableViewCell.h"
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
<UITableViewDelegate, UITableViewDataSource,
|
||||
UIActionSheetDelegate, UIAlertViewDelegate,
|
||||
UIPopoverControllerDelegate, ASIHTTPRequestDelegate,
|
||||
WEPopoverControllerDelegate, MCSwipeTableViewCellDelegate,
|
||||
WYPopoverControllerDelegate, MCSwipeTableViewCellDelegate,
|
||||
UIGestureRecognizerDelegate> {
|
||||
NewsBlurAppDelegate *appDelegate;
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
UITableView * storyTitlesTable;
|
||||
UIBarButtonItem * feedMarkReadButton;
|
||||
WEPopoverController *popoverController;
|
||||
WYPopoverController *popoverController;
|
||||
Class popoverClass;
|
||||
NBNotifier *notifier;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
|||
@property (nonatomic) IBOutlet UIBarButtonItem * spacer2BarButton;
|
||||
@property (nonatomic) IBOutlet UIBarButtonItem * separatorBarButton;
|
||||
@property (nonatomic) IBOutlet UIBarButtonItem * titleImageBarButton;
|
||||
@property (nonatomic, retain) WEPopoverController *popoverController;
|
||||
@property (nonatomic, retain) WYPopoverController *popoverController;
|
||||
@property (nonatomic, retain) NBNotifier *notifier;
|
||||
@property (nonatomic, retain) StoriesCollection *storiesCollection;
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
#import "JSON.h"
|
||||
#import "StringHelper.h"
|
||||
#import "Utilities.h"
|
||||
#import "UIBarButtonItem+WEPopover.h"
|
||||
#import "WEPopoverController.h"
|
||||
#import "WYPopoverController.h"
|
||||
#import "UIBarButtonItem+Image.h"
|
||||
#import "FeedDetailMenuViewController.h"
|
||||
#import "NBNotifier.h"
|
||||
|
@ -85,7 +84,7 @@
|
|||
name:UIContentSizeCategoryDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
popoverClass = [WEPopoverController class];
|
||||
popoverClass = [WYPopoverController class];
|
||||
self.storyTitlesTable.backgroundColor = UIColorFromRGB(0xf4f4f4);
|
||||
self.storyTitlesTable.separatorColor = UIColorFromRGB(0xE9E8E4);
|
||||
|
||||
|
@ -1739,7 +1738,7 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
|
|||
[appDelegate.masterContainerViewController showFeedDetailMenuPopover:self.settingsBarButton];
|
||||
} else {
|
||||
if (self.popoverController == nil) {
|
||||
self.popoverController = [[WEPopoverController alloc]
|
||||
self.popoverController = [[WYPopoverController alloc]
|
||||
initWithContentViewController:(UIViewController *)appDelegate.feedDetailMenuViewController];
|
||||
[appDelegate.feedDetailMenuViewController buildMenuOptions];
|
||||
self.popoverController.delegate = self;
|
||||
|
@ -1748,9 +1747,6 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
|
|||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
|
||||
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
|
||||
}
|
||||
NSInteger menuCount = [appDelegate.feedDetailMenuViewController.menuOptions count] + 2;
|
||||
[self.popoverController setPopoverContentSize:CGSizeMake(260, 38 * menuCount)];
|
||||
[self.popoverController presentPopoverFromBarButtonItem:self.settingsBarButton
|
||||
|
@ -2023,52 +2019,16 @@ didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
|
|||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WEPopoverControllerDelegate implementation
|
||||
#pragma mark WYPopoverControllerDelegate implementation
|
||||
|
||||
- (void)popoverControllerDidDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (void)popoverControllerDidDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//Safe to release the popover here
|
||||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//The popover is automatically dismissed if you click outside it, unless you return NO here
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (WEPopoverContainerViewProperties *)improvedContainerViewProperties {
|
||||
|
||||
WEPopoverContainerViewProperties *props = [WEPopoverContainerViewProperties alloc];
|
||||
NSString *bgImageName = nil;
|
||||
CGFloat bgMargin = 0.0;
|
||||
CGFloat bgCapSize = 0.0;
|
||||
CGFloat contentMargin = 5.0;
|
||||
|
||||
bgImageName = @"popoverBg.png";
|
||||
|
||||
// These constants are determined by the popoverBg.png image file and are image dependent
|
||||
bgMargin = 13; // margin width of 13 pixels on all sides popoverBg.png (62 pixels wide - 36 pixel background) / 2 == 26 / 2 == 13
|
||||
bgCapSize = 31; // ImageSize/2 == 62 / 2 == 31 pixels
|
||||
|
||||
props.leftBgMargin = bgMargin;
|
||||
props.rightBgMargin = bgMargin;
|
||||
props.topBgMargin = bgMargin;
|
||||
props.bottomBgMargin = bgMargin;
|
||||
props.leftBgCapSize = bgCapSize;
|
||||
props.topBgCapSize = bgCapSize;
|
||||
props.bgImageName = bgImageName;
|
||||
props.leftContentMargin = contentMargin;
|
||||
props.rightContentMargin = contentMargin - 1; // Need to shift one pixel for border to look correct
|
||||
props.topContentMargin = contentMargin;
|
||||
props.bottomContentMargin = contentMargin;
|
||||
|
||||
props.arrowMargin = 4.0;
|
||||
|
||||
props.upArrowImageName = @"popoverArrowUp.png";
|
||||
props.downArrowImageName = @"popoverArrowDown.png";
|
||||
props.leftArrowImageName = @"popoverArrowLeft.png";
|
||||
props.rightArrowImageName = @"popoverArrowRight.png";
|
||||
return props;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#import "ASIHTTPRequest.h"
|
||||
#import "PullToRefreshView.h"
|
||||
#import "BaseViewController.h"
|
||||
#import "WEPopoverController.h"
|
||||
#import "WYPopoverController.h"
|
||||
#import "NBNotifier.h"
|
||||
#import "IASKAppSettingsViewController.h"
|
||||
#import "MCSwipeTableViewCell.h"
|
||||
|
@ -23,7 +23,7 @@
|
|||
<UITableViewDelegate, UITableViewDataSource,
|
||||
UIAlertViewDelegate, PullToRefreshViewDelegate,
|
||||
ASIHTTPRequestDelegate, NSCacheDelegate,
|
||||
WEPopoverControllerDelegate,
|
||||
WYPopoverControllerDelegate,
|
||||
UIPopoverControllerDelegate,
|
||||
IASKSettingsDelegate,
|
||||
MCSwipeTableViewCellDelegate,
|
||||
|
@ -51,7 +51,7 @@ UIActionSheetDelegate> {
|
|||
UIBarButtonItem * settingsBarButton;
|
||||
UIBarButtonItem * activitiesButton;
|
||||
UISegmentedControl * intelligenceControl;
|
||||
WEPopoverController *popoverController;
|
||||
WYPopoverController *popoverController;
|
||||
Class popoverClass;
|
||||
NBNotifier *notifier;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ UIActionSheetDelegate> {
|
|||
@property (nonatomic) NSDate *lastUpdate;
|
||||
@property (nonatomic) NSCache *imageCache;
|
||||
@property (nonatomic) IBOutlet UISegmentedControl * intelligenceControl;
|
||||
@property (nonatomic, retain) WEPopoverController *popoverController;
|
||||
@property (nonatomic, retain) WYPopoverController *popoverController;
|
||||
@property (nonatomic) NSIndexPath *currentRowAtIndexPath;
|
||||
@property (nonatomic) NSInteger currentSection;
|
||||
@property (strong, nonatomic) IBOutlet UIView *noFocusMessage;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#import "JSON.h"
|
||||
#import "NBNotifier.h"
|
||||
#import "Utilities.h"
|
||||
#import "UIBarButtonItem+WEPopover.h"
|
||||
#import "UIBarButtonItem+Image.h"
|
||||
#import "AddSiteViewController.h"
|
||||
#import "FMDatabase.h"
|
||||
|
@ -100,7 +99,7 @@ static UIFont *userLabelFont;
|
|||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
popoverClass = [WEPopoverController class];
|
||||
popoverClass = [WYPopoverController class];
|
||||
|
||||
pull = [[PullToRefreshView alloc] initWithScrollView:self.feedTitlesTable];
|
||||
[pull setDelegate:self];
|
||||
|
@ -816,7 +815,7 @@ static UIFont *userLabelFont;
|
|||
[appDelegate.masterContainerViewController showSitePopover:self.addBarButton];
|
||||
} else {
|
||||
if (self.popoverController == nil) {
|
||||
self.popoverController = [[WEPopoverController alloc]
|
||||
self.popoverController = [[WYPopoverController alloc]
|
||||
initWithContentViewController:appDelegate.addSiteViewController];
|
||||
|
||||
self.popoverController.delegate = self;
|
||||
|
@ -825,9 +824,6 @@ static UIFont *userLabelFont;
|
|||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
|
||||
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
|
||||
}
|
||||
[self.popoverController setPopoverContentSize:CGSizeMake(self.view.frame.size.width - 36,
|
||||
self.view.frame.size.height - 28)];
|
||||
[self.popoverController presentPopoverFromBarButtonItem:self.addBarButton
|
||||
|
@ -843,7 +839,7 @@ static UIFont *userLabelFont;
|
|||
[appDelegate.masterContainerViewController showFeedMenuPopover:self.settingsBarButton];
|
||||
} else {
|
||||
if (self.popoverController == nil) {
|
||||
self.popoverController = [[WEPopoverController alloc]
|
||||
self.popoverController = [[WYPopoverController alloc]
|
||||
initWithContentViewController:appDelegate.feedsMenuViewController];
|
||||
|
||||
self.popoverController.delegate = self;
|
||||
|
@ -852,9 +848,6 @@ static UIFont *userLabelFont;
|
|||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
|
||||
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
|
||||
}
|
||||
[appDelegate.feedsMenuViewController view]; // Force viewDidLoad
|
||||
[self.popoverController setPopoverContentSize:CGSizeMake(200, 38 * [appDelegate.feedsMenuViewController.menuOptions count])];
|
||||
[self.popoverController presentPopoverFromBarButtonItem:self.settingsBarButton
|
||||
|
@ -865,7 +858,7 @@ static UIFont *userLabelFont;
|
|||
|
||||
- (IBAction)showInteractionsPopover:(id)sender {
|
||||
if (self.popoverController == nil) {
|
||||
self.popoverController = [[WEPopoverController alloc]
|
||||
self.popoverController = [[WYPopoverController alloc]
|
||||
initWithContentViewController:appDelegate.dashboardViewController];
|
||||
|
||||
self.popoverController.delegate = self;
|
||||
|
@ -874,9 +867,6 @@ static UIFont *userLabelFont;
|
|||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
|
||||
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
|
||||
}
|
||||
[self.popoverController setPopoverContentSize:CGSizeMake(self.view.frame.size.width - 36,
|
||||
self.view.frame.size.height - 60)];
|
||||
[self.popoverController presentPopoverFromBarButtonItem:self.activitiesButton
|
||||
|
@ -1852,57 +1842,18 @@ heightForHeaderInSection:(NSInteger)section {
|
|||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WEPopoverControllerDelegate implementation
|
||||
#pragma mark WYPopoverControllerDelegate implementation
|
||||
|
||||
- (void)popoverControllerDidDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (void)popoverControllerDidDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//Safe to release the popover here
|
||||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//The popover is automatically dismissed if you click outside it, unless you return NO here
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Thanks to Paul Solt for supplying these background images and container view properties
|
||||
*/
|
||||
- (WEPopoverContainerViewProperties *)improvedContainerViewProperties {
|
||||
|
||||
WEPopoverContainerViewProperties *props = [WEPopoverContainerViewProperties alloc];
|
||||
NSString *bgImageName = nil;
|
||||
CGFloat bgMargin = 0.0;
|
||||
CGFloat bgCapSize = 0.0;
|
||||
CGFloat contentMargin = 0.0;
|
||||
|
||||
bgImageName = @"popoverBg.png";
|
||||
|
||||
// These constants are determined by the popoverBg.png image file and are image dependent
|
||||
bgMargin = 13; // margin width of 13 pixels on all sides popoverBg.png (62 pixels wide - 36 pixel background) / 2 == 26 / 2 == 13
|
||||
bgCapSize = 31; // ImageSize/2 == 62 / 2 == 31 pixels
|
||||
|
||||
props.leftBgMargin = bgMargin;
|
||||
props.rightBgMargin = bgMargin;
|
||||
props.topBgMargin = bgMargin;
|
||||
props.bottomBgMargin = bgMargin;
|
||||
props.leftBgCapSize = bgCapSize;
|
||||
props.topBgCapSize = bgCapSize;
|
||||
props.bgImageName = bgImageName;
|
||||
props.leftContentMargin = contentMargin;
|
||||
props.rightContentMargin = contentMargin - 1; // Need to shift one pixel for border to look correct
|
||||
props.topContentMargin = contentMargin;
|
||||
props.bottomContentMargin = contentMargin;
|
||||
|
||||
props.arrowMargin = 4.0;
|
||||
|
||||
props.upArrowImageName = @"popoverArrowUp.png";
|
||||
props.downArrowImageName = @"popoverArrowDown.png";
|
||||
props.leftArrowImageName = @"popoverArrowLeft.png";
|
||||
props.rightArrowImageName = @"popoverArrowRight.png";
|
||||
return props;
|
||||
}
|
||||
|
||||
- (void)resetToolbar {
|
||||
self.navigationItem.leftBarButtonItem = nil;
|
||||
self.navigationItem.titleView = nil;
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
#import "BaseViewController.h"
|
||||
#import "NewsBlurAppDelegate.h"
|
||||
#import "WEPopoverController.h"
|
||||
#import "WYPopoverController.h"
|
||||
#import "THCircularProgressView.h"
|
||||
|
||||
@class NewsBlurAppDelegate;
|
||||
@class ASIHTTPRequest;
|
||||
|
||||
@interface StoryPageControl : BaseViewController
|
||||
<UIScrollViewDelegate, UIPopoverControllerDelegate, UIGestureRecognizerDelegate, WEPopoverControllerDelegate> {
|
||||
<UIScrollViewDelegate, UIPopoverControllerDelegate, UIGestureRecognizerDelegate, WYPopoverControllerDelegate> {
|
||||
|
||||
NewsBlurAppDelegate *appDelegate;
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
|||
UIView *progressView;
|
||||
UIView *progressViewContainer;
|
||||
|
||||
WEPopoverController *popoverController;
|
||||
WYPopoverController *popoverController;
|
||||
Class popoverClass;
|
||||
|
||||
BOOL isDraggingScrollview;
|
||||
|
@ -74,7 +74,7 @@
|
|||
@property (nonatomic) MBProgressHUD *storyHUD;
|
||||
@property (nonatomic) NSInteger scrollingToPage;
|
||||
|
||||
@property (nonatomic, strong) WEPopoverController *popoverController;
|
||||
@property (nonatomic, strong) WYPopoverController *popoverController;
|
||||
|
||||
- (void)resizeScrollView;
|
||||
- (void)applyNewIndex:(NSInteger)newIndex pageController:(StoryDetailViewController *)pageController;
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
[self.scrollView setShowsHorizontalScrollIndicator:NO];
|
||||
[self.scrollView setShowsVerticalScrollIndicator:NO];
|
||||
|
||||
popoverClass = [WEPopoverController class];
|
||||
popoverClass = [WYPopoverController class];
|
||||
|
||||
// adding HUD for progress bar
|
||||
CGFloat radius = 8;
|
||||
|
@ -953,7 +953,7 @@
|
|||
[appDelegate.masterContainerViewController showFontSettingsPopover:self.fontSettingsButton];
|
||||
} else {
|
||||
if (self.popoverController == nil) {
|
||||
self.popoverController = [[WEPopoverController alloc]
|
||||
self.popoverController = [[WYPopoverController alloc]
|
||||
initWithContentViewController:appDelegate.fontSettingsViewController];
|
||||
|
||||
self.popoverController.delegate = self;
|
||||
|
@ -962,9 +962,6 @@
|
|||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
|
||||
[self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
|
||||
}
|
||||
[self.popoverController setPopoverContentSize:CGSizeMake(240, 38*8-2)];
|
||||
[self.popoverController presentPopoverFromBarButtonItem:self.fontSettingsButton
|
||||
permittedArrowDirections:UIPopoverArrowDirectionAny
|
||||
|
@ -1063,55 +1060,16 @@
|
|||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WEPopoverControllerDelegate implementation
|
||||
#pragma mark WYPopoverControllerDelegate implementation
|
||||
|
||||
- (void)popoverControllerDidDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (void)popoverControllerDidDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//Safe to release the popover here
|
||||
self.popoverController = nil;
|
||||
}
|
||||
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)thePopoverController {
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WYPopoverController *)thePopoverController {
|
||||
//The popover is automatically dismissed if you click outside it, unless you return NO here
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Thanks to Paul Solt for supplying these background images and container view properties
|
||||
*/
|
||||
- (WEPopoverContainerViewProperties *)improvedContainerViewProperties {
|
||||
|
||||
WEPopoverContainerViewProperties *props = [WEPopoverContainerViewProperties alloc];
|
||||
NSString *bgImageName = nil;
|
||||
CGFloat bgMargin = 0.0;
|
||||
CGFloat bgCapSize = 0.0;
|
||||
CGFloat contentMargin = 5.0;
|
||||
|
||||
bgImageName = @"popoverBg.png";
|
||||
|
||||
// These constants are determined by the popoverBg.png image file and are image dependent
|
||||
bgMargin = 13; // margin width of 13 pixels on all sides popoverBg.png (62 pixels wide - 36 pixel background) / 2 == 26 / 2 == 13
|
||||
bgCapSize = 31; // ImageSize/2 == 62 / 2 == 31 pixels
|
||||
|
||||
props.leftBgMargin = bgMargin;
|
||||
props.rightBgMargin = bgMargin;
|
||||
props.topBgMargin = bgMargin;
|
||||
props.bottomBgMargin = bgMargin;
|
||||
props.leftBgCapSize = bgCapSize;
|
||||
props.topBgCapSize = bgCapSize;
|
||||
props.bgImageName = bgImageName;
|
||||
props.leftContentMargin = contentMargin;
|
||||
props.rightContentMargin = contentMargin - 1; // Need to shift one pixel for border to look correct
|
||||
props.topContentMargin = contentMargin;
|
||||
props.bottomContentMargin = contentMargin;
|
||||
|
||||
props.arrowMargin = 4.0;
|
||||
|
||||
props.upArrowImageName = @"popoverArrowUp.png";
|
||||
props.downArrowImageName = @"popoverArrowDown.png";
|
||||
props.leftArrowImageName = @"popoverArrowLeft.png";
|
||||
props.rightArrowImageName = @"popoverArrowRight.png";
|
||||
return props;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -61,10 +61,6 @@
|
|||
43A3914B15B73A7B0074B212 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A3913F15B73A7B0074B212 /* AFURLConnectionOperation.m */; };
|
||||
43A3914C15B73A7B0074B212 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A3914115B73A7B0074B212 /* AFXMLRequestOperation.m */; };
|
||||
43A3914D15B73A7B0074B212 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A3914315B73A7B0074B212 /* UIImageView+AFNetworking.m */; };
|
||||
43A4BAC815C8663600F3B8D4 /* UIBarButtonItem+WEPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4BAC015C8663600F3B8D4 /* UIBarButtonItem+WEPopover.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4BAC915C8663600F3B8D4 /* WEPopoverContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4BAC215C8663600F3B8D4 /* WEPopoverContainerView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4BACA15C8663600F3B8D4 /* WEPopoverController.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4BAC415C8663600F3B8D4 /* WEPopoverController.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4BACB15C8663600F3B8D4 /* WETouchableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 43A4BAC715C8663600F3B8D4 /* WETouchableView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||
43A4BADB15C866FA00F3B8D4 /* popoverArrowDown.png in Resources */ = {isa = PBXBuildFile; fileRef = 43A4BACC15C866FA00F3B8D4 /* popoverArrowDown.png */; };
|
||||
43A4BADC15C866FA00F3B8D4 /* popoverArrowDown@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 43A4BACD15C866FA00F3B8D4 /* popoverArrowDown@2x.png */; };
|
||||
43A4BADD15C866FA00F3B8D4 /* popoverArrowDownSimple.png in Resources */ = {isa = PBXBuildFile; fileRef = 43A4BACE15C866FA00F3B8D4 /* popoverArrowDownSimple.png */; };
|
||||
|
@ -266,6 +262,8 @@
|
|||
FF6281FA1A09614C00271FDB /* all@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF6281F91A09614C00271FDB /* all@3x.png */; };
|
||||
FF6281FC1A0962FA00271FDB /* unread_green@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF6281FB1A0962FA00271FDB /* unread_green@3x.png */; };
|
||||
FF6281FE1A09641100271FDB /* unread_yellow@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = FF6281FD1A09641100271FDB /* unread_yellow@3x.png */; };
|
||||
FF6282031A09685800271FDB /* WYPopoverController.m in Sources */ = {isa = PBXBuildFile; fileRef = FF6282001A09685800271FDB /* WYPopoverController.m */; };
|
||||
FF6282041A09685800271FDB /* WYStoryboardPopoverSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = FF6282021A09685800271FDB /* WYStoryboardPopoverSegue.m */; };
|
||||
FF6618C8176184560039913B /* NBNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = FF6618C7176184560039913B /* NBNotifier.m */; };
|
||||
FF67D3B2168924C40057A7DA /* TrainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FF67D3B1168924C40057A7DA /* TrainerViewController.m */; };
|
||||
FF67D3B7168977690057A7DA /* TrainerViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FF67D3B6168977690057A7DA /* TrainerViewController.xib */; };
|
||||
|
@ -776,15 +774,6 @@
|
|||
43A3914115B73A7B0074B212 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = "<group>"; };
|
||||
43A3914215B73A7B0074B212 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = "<group>"; };
|
||||
43A3914315B73A7B0074B212 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = "<group>"; };
|
||||
43A4BABF15C8663600F3B8D4 /* UIBarButtonItem+WEPopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+WEPopover.h"; sourceTree = "<group>"; };
|
||||
43A4BAC015C8663600F3B8D4 /* UIBarButtonItem+WEPopover.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIBarButtonItem+WEPopover.m"; sourceTree = "<group>"; };
|
||||
43A4BAC115C8663600F3B8D4 /* WEPopoverContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WEPopoverContainerView.h; sourceTree = "<group>"; };
|
||||
43A4BAC215C8663600F3B8D4 /* WEPopoverContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WEPopoverContainerView.m; sourceTree = "<group>"; };
|
||||
43A4BAC315C8663600F3B8D4 /* WEPopoverController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WEPopoverController.h; sourceTree = "<group>"; };
|
||||
43A4BAC415C8663600F3B8D4 /* WEPopoverController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WEPopoverController.m; sourceTree = "<group>"; };
|
||||
43A4BAC515C8663600F3B8D4 /* WEPopoverParentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WEPopoverParentView.h; sourceTree = "<group>"; };
|
||||
43A4BAC615C8663600F3B8D4 /* WETouchableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WETouchableView.h; sourceTree = "<group>"; };
|
||||
43A4BAC715C8663600F3B8D4 /* WETouchableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WETouchableView.m; sourceTree = "<group>"; };
|
||||
43A4BACC15C866FA00F3B8D4 /* popoverArrowDown.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = popoverArrowDown.png; sourceTree = "<group>"; };
|
||||
43A4BACD15C866FA00F3B8D4 /* popoverArrowDown@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "popoverArrowDown@2x.png"; sourceTree = "<group>"; };
|
||||
43A4BACE15C866FA00F3B8D4 /* popoverArrowDownSimple.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = popoverArrowDownSimple.png; sourceTree = "<group>"; };
|
||||
|
@ -1053,6 +1042,10 @@
|
|||
FF6281F91A09614C00271FDB /* all@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "all@3x.png"; sourceTree = "<group>"; };
|
||||
FF6281FB1A0962FA00271FDB /* unread_green@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "unread_green@3x.png"; sourceTree = "<group>"; };
|
||||
FF6281FD1A09641100271FDB /* unread_yellow@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "unread_yellow@3x.png"; sourceTree = "<group>"; };
|
||||
FF6281FF1A09685800271FDB /* WYPopoverController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WYPopoverController.h; path = "../../../../../Downloads/WYPopoverController-master/WYPopoverController/WYPopoverController.h"; sourceTree = "<group>"; };
|
||||
FF6282001A09685800271FDB /* WYPopoverController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WYPopoverController.m; path = "../../../../../Downloads/WYPopoverController-master/WYPopoverController/WYPopoverController.m"; sourceTree = "<group>"; };
|
||||
FF6282011A09685800271FDB /* WYStoryboardPopoverSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WYStoryboardPopoverSegue.h; path = "../../../../../Downloads/WYPopoverController-master/WYPopoverController/WYStoryboardPopoverSegue.h"; sourceTree = "<group>"; };
|
||||
FF6282021A09685800271FDB /* WYStoryboardPopoverSegue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WYStoryboardPopoverSegue.m; path = "../../../../../Downloads/WYPopoverController-master/WYPopoverController/WYStoryboardPopoverSegue.m"; sourceTree = "<group>"; };
|
||||
FF6618C6176184560039913B /* NBNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBNotifier.h; sourceTree = "<group>"; };
|
||||
FF6618C7176184560039913B /* NBNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBNotifier.m; sourceTree = "<group>"; };
|
||||
FF67D3B0168924C40057A7DA /* TrainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrainerViewController.h; sourceTree = "<group>"; };
|
||||
|
@ -2234,15 +2227,10 @@
|
|||
43A4BABE15C8663600F3B8D4 /* Popover */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
43A4BABF15C8663600F3B8D4 /* UIBarButtonItem+WEPopover.h */,
|
||||
43A4BAC015C8663600F3B8D4 /* UIBarButtonItem+WEPopover.m */,
|
||||
43A4BAC115C8663600F3B8D4 /* WEPopoverContainerView.h */,
|
||||
43A4BAC215C8663600F3B8D4 /* WEPopoverContainerView.m */,
|
||||
43A4BAC315C8663600F3B8D4 /* WEPopoverController.h */,
|
||||
43A4BAC415C8663600F3B8D4 /* WEPopoverController.m */,
|
||||
43A4BAC515C8663600F3B8D4 /* WEPopoverParentView.h */,
|
||||
43A4BAC615C8663600F3B8D4 /* WETouchableView.h */,
|
||||
43A4BAC715C8663600F3B8D4 /* WETouchableView.m */,
|
||||
FF6281FF1A09685800271FDB /* WYPopoverController.h */,
|
||||
FF6282001A09685800271FDB /* WYPopoverController.m */,
|
||||
FF6282011A09685800271FDB /* WYStoryboardPopoverSegue.h */,
|
||||
FF6282021A09685800271FDB /* WYStoryboardPopoverSegue.m */,
|
||||
);
|
||||
path = Popover;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3751,12 +3739,8 @@
|
|||
43E8382215BC73EB000553BE /* FirstTimeUserAddSitesViewController.m in Sources */,
|
||||
FFA0481819CA54A800618DC4 /* OSKPinboardUtility.m in Sources */,
|
||||
436ACA8D15BF1088004E01CC /* NBContainerViewController.m in Sources */,
|
||||
43A4BAC815C8663600F3B8D4 /* UIBarButtonItem+WEPopover.m in Sources */,
|
||||
FFA047EB19CA54A800618DC4 /* OSKActivityIndicatorItem.m in Sources */,
|
||||
43A4BAC915C8663600F3B8D4 /* WEPopoverContainerView.m in Sources */,
|
||||
FFA0483E19CA5B8400618DC4 /* EventWindow.m in Sources */,
|
||||
43A4BACA15C8663600F3B8D4 /* WEPopoverController.m in Sources */,
|
||||
43A4BACB15C8663600F3B8D4 /* WETouchableView.m in Sources */,
|
||||
432EBD2315D1D4070000729D /* AddSiteTableCell.m in Sources */,
|
||||
FFA047D719CA54A800618DC4 /* NSDate+OSK_ISO8601.m in Sources */,
|
||||
FFA0481B19CA54A800618DC4 /* OSKPresentationManager.m in Sources */,
|
||||
|
@ -3802,6 +3786,7 @@
|
|||
FF753CD0175858FC00344EC9 /* FMDatabasePool.m in Sources */,
|
||||
FF753CD1175858FC00344EC9 /* FMDatabaseQueue.m in Sources */,
|
||||
FF753CD3175858FC00344EC9 /* FMResultSet.m in Sources */,
|
||||
FF6282041A09685800271FDB /* WYStoryboardPopoverSegue.m in Sources */,
|
||||
FF6618C8176184560039913B /* NBNotifier.m in Sources */,
|
||||
FF03AFF319F87F2E0063002A /* TUSafariActivity.m in Sources */,
|
||||
FFA0482419CA54A800618DC4 /* OSKSessionController_Pad.m in Sources */,
|
||||
|
@ -3824,6 +3809,7 @@
|
|||
FFF1E4BC177504CA00BF59D3 /* IASKSettingsReader.m in Sources */,
|
||||
FFA0480719CA54A800618DC4 /* OSKInstapaperUtility.m in Sources */,
|
||||
FFF1E4BD177504CA00BF59D3 /* IASKSettingsStore.m in Sources */,
|
||||
FF6282031A09685800271FDB /* WYPopoverController.m in Sources */,
|
||||
FFF1E4BE177504CA00BF59D3 /* IASKSettingsStoreFile.m in Sources */,
|
||||
FFF1E4BF177504CA00BF59D3 /* IASKSettingsStoreUserDefaults.m in Sources */,
|
||||
FFF1E4C0177504CA00BF59D3 /* IASKSpecifier.m in Sources */,
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* UIBarButtonItem+WEPopover.h
|
||||
* WEPopover
|
||||
*
|
||||
* Created by Werner Altewischer on 07/05/11.
|
||||
* Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIBarButtonItem(WEPopover)
|
||||
|
||||
- (CGRect)frameInView:(UIView *)v;
|
||||
- (UIView *)superview;
|
||||
|
||||
@end
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* UIBarButtonItem+WEPopover.m
|
||||
* WEPopover
|
||||
*
|
||||
* Created by Werner Altewischer on 07/05/11.
|
||||
* Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#import "UIBarButtonItem+WEPopover.h"
|
||||
|
||||
@implementation UIBarButtonItem(WEPopover)
|
||||
|
||||
- (CGRect)frameInView:(UIView *)v {
|
||||
|
||||
UIView *theView = self.customView;
|
||||
if (!theView && [self respondsToSelector:@selector(view)]) {
|
||||
theView = [self performSelector:@selector(view)];
|
||||
}
|
||||
|
||||
UIView *parentView = theView.superview;
|
||||
NSArray *subviews = parentView.subviews;
|
||||
|
||||
NSUInteger indexOfView = [subviews indexOfObject:theView];
|
||||
NSUInteger subviewCount = subviews.count;
|
||||
|
||||
if (subviewCount > 0 && indexOfView != NSNotFound) {
|
||||
UIView *button = [parentView.subviews objectAtIndex:indexOfView];
|
||||
return [button convertRect:button.bounds toView:v];
|
||||
} else {
|
||||
return CGRectZero;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIView *)superview {
|
||||
|
||||
UIView *theView = self.customView;
|
||||
if (!theView && [self respondsToSelector:@selector(view)]) {
|
||||
theView = [self performSelector:@selector(view)];
|
||||
}
|
||||
|
||||
UIView *parentView = theView.superview;
|
||||
return parentView;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,100 +0,0 @@
|
|||
//
|
||||
// WEPopoverContainerView.h
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 02/09/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* @brief Properties for the container view determining the area where the actual content view can/may be displayed. Also Images can be supplied for the arrow images and background.
|
||||
*/
|
||||
@interface WEPopoverContainerViewProperties : NSObject
|
||||
{
|
||||
NSString *bgImageName;
|
||||
NSString *upArrowImageName;
|
||||
NSString *downArrowImageName;
|
||||
NSString *leftArrowImageName;
|
||||
NSString *rightArrowImageName;
|
||||
CGFloat leftBgMargin;
|
||||
CGFloat rightBgMargin;
|
||||
CGFloat topBgMargin;
|
||||
CGFloat bottomBgMargin;
|
||||
NSInteger topBgCapSize;
|
||||
NSInteger leftBgCapSize;
|
||||
CGFloat arrowMargin;
|
||||
}
|
||||
|
||||
@property(nonatomic, retain) NSString *bgImageName;
|
||||
@property(nonatomic, retain) NSString *upArrowImageName;
|
||||
@property(nonatomic, retain) NSString *downArrowImageName;
|
||||
@property(nonatomic, retain) NSString *leftArrowImageName;
|
||||
@property(nonatomic, retain) NSString *rightArrowImageName;
|
||||
@property(nonatomic, assign) CGFloat leftBgMargin;
|
||||
@property(nonatomic, assign) CGFloat rightBgMargin;
|
||||
@property(nonatomic, assign) CGFloat topBgMargin;
|
||||
@property(nonatomic, assign) CGFloat bottomBgMargin;
|
||||
@property(nonatomic, assign) CGFloat leftContentMargin;
|
||||
@property(nonatomic, assign) CGFloat rightContentMargin;
|
||||
@property(nonatomic, assign) CGFloat topContentMargin;
|
||||
@property(nonatomic, assign) CGFloat bottomContentMargin;
|
||||
@property(nonatomic, assign) NSInteger topBgCapSize;
|
||||
@property(nonatomic, assign) NSInteger leftBgCapSize;
|
||||
@property(nonatomic, assign) CGFloat arrowMargin;
|
||||
|
||||
@end
|
||||
|
||||
@class WEPopoverContainerView;
|
||||
|
||||
/**
|
||||
* @brief Container/background view for displaying a popover view.
|
||||
*/
|
||||
@interface WEPopoverContainerView : UIView {
|
||||
UIImage *bgImage;
|
||||
UIImage *arrowImage;
|
||||
|
||||
WEPopoverContainerViewProperties *properties;
|
||||
|
||||
UIPopoverArrowDirection arrowDirection;
|
||||
|
||||
CGRect arrowRect;
|
||||
CGRect bgRect;
|
||||
CGPoint offset;
|
||||
CGPoint arrowOffset;
|
||||
|
||||
CGSize correctedSize;
|
||||
UIView *contentView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The current arrow direction for the popover.
|
||||
*/
|
||||
@property (nonatomic, readonly) UIPopoverArrowDirection arrowDirection;
|
||||
|
||||
/**
|
||||
* @brief The content view being displayed.
|
||||
*/
|
||||
@property (nonatomic, retain) UIView *contentView;
|
||||
|
||||
/**
|
||||
* @brief Initializes the position of the popover with a size, anchor rect, display area and permitted arrow directions and optionally the properties.
|
||||
* If the last is not supplied the defaults are taken (requires images to be present in bundle representing a black rounded background with partial transparency).
|
||||
*/
|
||||
- (id)initWithSize:(CGSize)theSize
|
||||
anchorRect:(CGRect)anchorRect
|
||||
displayArea:(CGRect)displayArea
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)permittedArrowDirections
|
||||
properties:(WEPopoverContainerViewProperties *)properties;
|
||||
|
||||
/**
|
||||
* @brief To update the position of the popover with a new anchor rect, display area and permitted arrow directions
|
||||
*/
|
||||
- (void)updatePositionWithSize:(CGSize)theSize
|
||||
anchorRect:(CGRect)anchorRect
|
||||
displayArea:(CGRect)displayArea
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)permittedArrowDirections;
|
||||
|
||||
@end
|
|
@ -1,366 +0,0 @@
|
|||
//
|
||||
// WEPopoverContainerViewProperties.m
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 02/09/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WEPopoverContainerView.h"
|
||||
|
||||
@implementation WEPopoverContainerViewProperties
|
||||
|
||||
@synthesize bgImageName, upArrowImageName, downArrowImageName, leftArrowImageName, rightArrowImageName, topBgMargin, bottomBgMargin, leftBgMargin, rightBgMargin, topBgCapSize, leftBgCapSize;
|
||||
@synthesize leftContentMargin, rightContentMargin, topContentMargin, bottomContentMargin, arrowMargin;
|
||||
|
||||
- (void)dealloc {
|
||||
self.bgImageName = nil;
|
||||
self.upArrowImageName = nil;
|
||||
self.downArrowImageName = nil;
|
||||
self.leftArrowImageName = nil;
|
||||
self.rightArrowImageName = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface WEPopoverContainerView(Private)
|
||||
|
||||
- (void)determineGeometryForSize:(CGSize)theSize anchorRect:(CGRect)anchorRect displayArea:(CGRect)displayArea permittedArrowDirections:(UIPopoverArrowDirection)permittedArrowDirections;
|
||||
- (CGRect)contentRect;
|
||||
- (CGSize)contentSize;
|
||||
- (void)setProperties:(WEPopoverContainerViewProperties *)props;
|
||||
- (void)initFrame;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WEPopoverContainerView
|
||||
|
||||
@synthesize arrowDirection, contentView;
|
||||
|
||||
- (id)initWithSize:(CGSize)theSize
|
||||
anchorRect:(CGRect)anchorRect
|
||||
displayArea:(CGRect)displayArea
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)permittedArrowDirections
|
||||
properties:(WEPopoverContainerViewProperties *)theProperties {
|
||||
if ((self = [super initWithFrame:CGRectZero])) {
|
||||
|
||||
[self setProperties:theProperties];
|
||||
correctedSize = CGSizeMake(theSize.width + properties.leftBgMargin + properties.rightBgMargin + properties.leftContentMargin + properties.rightContentMargin,
|
||||
theSize.height + properties.topBgMargin + properties.bottomBgMargin + properties.topContentMargin + properties.bottomContentMargin);
|
||||
[self determineGeometryForSize:correctedSize anchorRect:anchorRect displayArea:displayArea permittedArrowDirections:permittedArrowDirections];
|
||||
[self initFrame];
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
UIImage *theImage = [UIImage imageNamed:properties.bgImageName];
|
||||
bgImage = [[theImage stretchableImageWithLeftCapWidth:properties.leftBgCapSize topCapHeight:properties.topBgCapSize] retain];
|
||||
|
||||
self.clipsToBounds = YES;
|
||||
self.userInteractionEnabled = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[properties release];
|
||||
[contentView release];
|
||||
[bgImage release];
|
||||
[arrowImage release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
[bgImage drawInRect:bgRect blendMode:kCGBlendModeNormal alpha:1.0];
|
||||
[arrowImage drawInRect:arrowRect blendMode:kCGBlendModeNormal alpha:1.0];
|
||||
}
|
||||
|
||||
- (void)updatePositionWithSize:(CGSize)theSize
|
||||
anchorRect:(CGRect)anchorRect
|
||||
displayArea:(CGRect)displayArea
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)permittedArrowDirections {
|
||||
|
||||
correctedSize = CGSizeMake(theSize.width + properties.leftBgMargin + properties.rightBgMargin + properties.leftContentMargin + properties.rightContentMargin,
|
||||
theSize.height + properties.topBgMargin + properties.bottomBgMargin + properties.topContentMargin + properties.bottomContentMargin);
|
||||
[self determineGeometryForSize:correctedSize anchorRect:anchorRect displayArea:displayArea permittedArrowDirections:permittedArrowDirections];
|
||||
[self initFrame];
|
||||
[self setNeedsDisplay];
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
|
||||
return CGRectContainsPoint(self.contentRect, point);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
}
|
||||
|
||||
- (void)setContentView:(UIView *)v {
|
||||
if (v != contentView) {
|
||||
[contentView release];
|
||||
contentView = [v retain];
|
||||
contentView.frame = self.contentRect;
|
||||
[self addSubview:contentView];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation WEPopoverContainerView(Private)
|
||||
|
||||
- (void)initFrame {
|
||||
CGRect theFrame = CGRectOffset(CGRectUnion(bgRect, arrowRect), offset.x, offset.y);
|
||||
|
||||
//If arrow rect origin is < 0 the frame above is extended to include it so we should offset the other rects
|
||||
arrowOffset = CGPointMake(MAX(0, -arrowRect.origin.x), MAX(0, -arrowRect.origin.y));
|
||||
bgRect = CGRectOffset(bgRect, arrowOffset.x, arrowOffset.y);
|
||||
arrowRect = CGRectOffset(arrowRect, arrowOffset.x, arrowOffset.y);
|
||||
|
||||
self.frame = CGRectIntegral(theFrame);
|
||||
}
|
||||
|
||||
- (CGSize)contentSize {
|
||||
return self.contentRect.size;
|
||||
}
|
||||
|
||||
- (CGRect)contentRect {
|
||||
CGRect rect = CGRectMake(properties.leftBgMargin + properties.leftContentMargin + arrowOffset.x,
|
||||
properties.topBgMargin + properties.topContentMargin + arrowOffset.y,
|
||||
bgRect.size.width - properties.leftBgMargin - properties.rightBgMargin - properties.leftContentMargin - properties.rightContentMargin,
|
||||
bgRect.size.height - properties.topBgMargin - properties.bottomBgMargin - properties.topContentMargin - properties.bottomContentMargin);
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (void)setProperties:(WEPopoverContainerViewProperties *)props {
|
||||
if (properties != props) {
|
||||
[properties release];
|
||||
properties = [props retain];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)determineGeometryForSize:(CGSize)theSize anchorRect:(CGRect)anchorRect displayArea:(CGRect)displayArea permittedArrowDirections:(UIPopoverArrowDirection)supportedArrowDirections {
|
||||
|
||||
//Determine the frame, it should not go outside the display area
|
||||
UIPopoverArrowDirection theArrowDirection = UIPopoverArrowDirectionUp;
|
||||
|
||||
offset = CGPointZero;
|
||||
bgRect = CGRectZero;
|
||||
arrowRect = CGRectZero;
|
||||
arrowDirection = UIPopoverArrowDirectionUnknown;
|
||||
|
||||
CGFloat biggestSurface = 0.0f;
|
||||
CGFloat currentMinMargin = 0.0f;
|
||||
|
||||
UIImage *upArrowImage = [UIImage imageNamed:properties.upArrowImageName];
|
||||
UIImage *downArrowImage = [UIImage imageNamed:properties.downArrowImageName];
|
||||
UIImage *leftArrowImage = [UIImage imageNamed:properties.leftArrowImageName];
|
||||
UIImage *rightArrowImage = [UIImage imageNamed:properties.rightArrowImageName];
|
||||
|
||||
while (theArrowDirection <= UIPopoverArrowDirectionRight) {
|
||||
|
||||
if ((supportedArrowDirections & theArrowDirection)) {
|
||||
|
||||
CGRect theBgRect = CGRectMake(0, 0, theSize.width, theSize.height);
|
||||
CGRect theArrowRect = CGRectZero;
|
||||
CGPoint theOffset = CGPointZero;
|
||||
CGFloat xArrowOffset = 0.0;
|
||||
CGFloat yArrowOffset = 0.0;
|
||||
CGPoint anchorPoint = CGPointZero;
|
||||
|
||||
switch (theArrowDirection) {
|
||||
case UIPopoverArrowDirectionUp:
|
||||
|
||||
anchorPoint = CGPointMake(CGRectGetMidX(anchorRect) - displayArea.origin.x, CGRectGetMaxY(anchorRect) - displayArea.origin.y);
|
||||
|
||||
xArrowOffset = theSize.width / 2 - upArrowImage.size.width / 2;
|
||||
yArrowOffset = properties.topBgMargin - upArrowImage.size.height;
|
||||
|
||||
theOffset = CGPointMake(anchorPoint.x - xArrowOffset - upArrowImage.size.width / 2, anchorPoint.y - yArrowOffset);
|
||||
|
||||
if (theOffset.x < 0) {
|
||||
xArrowOffset += theOffset.x;
|
||||
theOffset.x = 0;
|
||||
} else if (theOffset.x + theSize.width > displayArea.size.width) {
|
||||
xArrowOffset += (theOffset.x + theSize.width - displayArea.size.width);
|
||||
theOffset.x = displayArea.size.width - theSize.width;
|
||||
}
|
||||
|
||||
//Cap the arrow offset
|
||||
xArrowOffset = MAX(xArrowOffset, properties.leftBgMargin + properties.arrowMargin);
|
||||
xArrowOffset = MIN(xArrowOffset, theSize.width - properties.rightBgMargin - properties.arrowMargin - upArrowImage.size.width);
|
||||
|
||||
theArrowRect = CGRectMake(xArrowOffset, yArrowOffset, upArrowImage.size.width, upArrowImage.size.height);
|
||||
|
||||
break;
|
||||
case UIPopoverArrowDirectionDown:
|
||||
|
||||
anchorPoint = CGPointMake(CGRectGetMidX(anchorRect) - displayArea.origin.x, CGRectGetMinY(anchorRect) - displayArea.origin.y);
|
||||
|
||||
xArrowOffset = theSize.width / 2 - downArrowImage.size.width / 2;
|
||||
yArrowOffset = theSize.height - properties.bottomBgMargin;
|
||||
|
||||
theOffset = CGPointMake(anchorPoint.x - xArrowOffset - downArrowImage.size.width / 2, anchorPoint.y - yArrowOffset - downArrowImage.size.height);
|
||||
|
||||
if (theOffset.x < 0) {
|
||||
xArrowOffset += theOffset.x;
|
||||
theOffset.x = 0;
|
||||
} else if (theOffset.x + theSize.width > displayArea.size.width) {
|
||||
xArrowOffset += (theOffset.x + theSize.width - displayArea.size.width);
|
||||
theOffset.x = displayArea.size.width - theSize.width;
|
||||
}
|
||||
|
||||
//Cap the arrow offset
|
||||
xArrowOffset = MAX(xArrowOffset, properties.leftBgMargin + properties.arrowMargin);
|
||||
xArrowOffset = MIN(xArrowOffset, theSize.width - properties.rightBgMargin - properties.arrowMargin - downArrowImage.size.width);
|
||||
|
||||
theArrowRect = CGRectMake(xArrowOffset , yArrowOffset, downArrowImage.size.width, downArrowImage.size.height);
|
||||
|
||||
break;
|
||||
case UIPopoverArrowDirectionLeft:
|
||||
|
||||
anchorPoint = CGPointMake(CGRectGetMaxX(anchorRect) - displayArea.origin.x, CGRectGetMidY(anchorRect) - displayArea.origin.y);
|
||||
|
||||
xArrowOffset = properties.leftBgMargin - leftArrowImage.size.width;
|
||||
yArrowOffset = theSize.height / 2 - leftArrowImage.size.height / 2;
|
||||
|
||||
theOffset = CGPointMake(anchorPoint.x - xArrowOffset, anchorPoint.y - yArrowOffset - leftArrowImage.size.height / 2);
|
||||
|
||||
if (theOffset.y < 0) {
|
||||
yArrowOffset += theOffset.y;
|
||||
theOffset.y = 0;
|
||||
} else if (theOffset.y + theSize.height > displayArea.size.height) {
|
||||
yArrowOffset += (theOffset.y + theSize.height - displayArea.size.height);
|
||||
theOffset.y = displayArea.size.height - theSize.height;
|
||||
}
|
||||
|
||||
//Cap the arrow offset
|
||||
yArrowOffset = MAX(yArrowOffset, properties.topBgMargin + properties.arrowMargin);
|
||||
yArrowOffset = MIN(yArrowOffset, theSize.height - properties.bottomBgMargin - properties.arrowMargin - leftArrowImage.size.height);
|
||||
|
||||
theArrowRect = CGRectMake(xArrowOffset, yArrowOffset, leftArrowImage.size.width, leftArrowImage.size.height);
|
||||
|
||||
break;
|
||||
case UIPopoverArrowDirectionRight:
|
||||
|
||||
anchorPoint = CGPointMake(CGRectGetMinX(anchorRect) - displayArea.origin.x, CGRectGetMidY(anchorRect) - displayArea.origin.y);
|
||||
|
||||
xArrowOffset = theSize.width - properties.rightBgMargin;
|
||||
yArrowOffset = theSize.height / 2 - rightArrowImage.size.width / 2;
|
||||
|
||||
theOffset = CGPointMake(anchorPoint.x - xArrowOffset - rightArrowImage.size.width, anchorPoint.y - yArrowOffset - rightArrowImage.size.height / 2);
|
||||
|
||||
if (theOffset.y < 0) {
|
||||
yArrowOffset += theOffset.y;
|
||||
theOffset.y = 0;
|
||||
} else if (theOffset.y + theSize.height > displayArea.size.height) {
|
||||
yArrowOffset += (theOffset.y + theSize.height - displayArea.size.height);
|
||||
theOffset.y = displayArea.size.height - theSize.height;
|
||||
}
|
||||
|
||||
//Cap the arrow offset
|
||||
yArrowOffset = MAX(yArrowOffset, properties.topBgMargin + properties.arrowMargin);
|
||||
yArrowOffset = MIN(yArrowOffset, theSize.height - properties.bottomBgMargin - properties.arrowMargin - rightArrowImage.size.height);
|
||||
|
||||
theArrowRect = CGRectMake(xArrowOffset, yArrowOffset, rightArrowImage.size.width, rightArrowImage.size.height);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CGRect bgFrame = CGRectOffset(theBgRect, theOffset.x, theOffset.y);
|
||||
|
||||
CGFloat minMarginLeft = CGRectGetMinX(bgFrame);
|
||||
CGFloat minMarginRight = CGRectGetWidth(displayArea) - CGRectGetMaxX(bgFrame);
|
||||
CGFloat minMarginTop = CGRectGetMinY(bgFrame);
|
||||
CGFloat minMarginBottom = CGRectGetHeight(displayArea) - CGRectGetMaxY(bgFrame);
|
||||
|
||||
if (minMarginLeft < 0) {
|
||||
// Popover is too wide and clipped on the left; decrease width
|
||||
// and move it to the right
|
||||
theOffset.x -= minMarginLeft;
|
||||
theBgRect.size.width += minMarginLeft;
|
||||
minMarginLeft = 0;
|
||||
if (theArrowDirection == UIPopoverArrowDirectionRight) {
|
||||
theArrowRect.origin.x = CGRectGetMaxX(theBgRect) - properties.rightBgMargin;
|
||||
}
|
||||
}
|
||||
if (minMarginRight < 0) {
|
||||
// Popover is too wide and clipped on the right; decrease width.
|
||||
theBgRect.size.width += minMarginRight;
|
||||
minMarginRight = 0;
|
||||
if (theArrowDirection == UIPopoverArrowDirectionLeft) {
|
||||
theArrowRect.origin.x = CGRectGetMinX(theBgRect) - leftArrowImage.size.width + properties.leftBgMargin;
|
||||
}
|
||||
}
|
||||
if (minMarginTop < 0) {
|
||||
// Popover is too high and clipped at the top; decrease height
|
||||
// and move it down
|
||||
theOffset.y -= minMarginTop;
|
||||
theBgRect.size.height += minMarginTop;
|
||||
minMarginTop = 0;
|
||||
if (theArrowDirection == UIPopoverArrowDirectionDown) {
|
||||
theArrowRect.origin.y = CGRectGetMaxY(theBgRect) - properties.bottomBgMargin;
|
||||
}
|
||||
}
|
||||
if (minMarginBottom < 0) {
|
||||
// Popover is too high and clipped at the bottom; decrease height.
|
||||
theBgRect.size.height += minMarginBottom;
|
||||
minMarginBottom = 0;
|
||||
if (theArrowDirection == UIPopoverArrowDirectionUp) {
|
||||
theArrowRect.origin.y = CGRectGetMinY(theBgRect) - upArrowImage.size.height + properties.topBgMargin;
|
||||
}
|
||||
}
|
||||
|
||||
CGFloat minMargin = MIN(minMarginLeft, minMarginRight);
|
||||
minMargin = MIN(minMargin, minMarginTop);
|
||||
minMargin = MIN(minMargin, minMarginBottom);
|
||||
|
||||
// Calculate intersection and surface
|
||||
CGFloat surface = theBgRect.size.width * theBgRect.size.height;
|
||||
|
||||
if (surface >= biggestSurface && minMargin >= currentMinMargin) {
|
||||
biggestSurface = surface;
|
||||
offset = CGPointMake(theOffset.x + displayArea.origin.x, theOffset.y + displayArea.origin.y);
|
||||
arrowRect = theArrowRect;
|
||||
bgRect = theBgRect;
|
||||
arrowDirection = theArrowDirection;
|
||||
currentMinMargin = minMargin;
|
||||
}
|
||||
}
|
||||
|
||||
theArrowDirection <<= 1;
|
||||
}
|
||||
|
||||
switch (arrowDirection) {
|
||||
case UIPopoverArrowDirectionUp:
|
||||
arrowImage = [upArrowImage retain];
|
||||
break;
|
||||
case UIPopoverArrowDirectionDown:
|
||||
arrowImage = [downArrowImage retain];
|
||||
break;
|
||||
case UIPopoverArrowDirectionLeft:
|
||||
arrowImage = [leftArrowImage retain];
|
||||
break;
|
||||
case UIPopoverArrowDirectionRight:
|
||||
arrowImage = [rightArrowImage retain];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,75 +0,0 @@
|
|||
//
|
||||
// WEPopoverController.h
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 02/09/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WEPopoverContainerView.h"
|
||||
#import "WETouchableView.h"
|
||||
|
||||
@class WEPopoverController;
|
||||
|
||||
@protocol WEPopoverControllerDelegate<NSObject>
|
||||
|
||||
- (void)popoverControllerDidDismissPopover:(WEPopoverController *)popoverController;
|
||||
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)popoverController;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* @brief Popover controller for the iPhone, mimicing the iPad UIPopoverController interface. See that class for more details.
|
||||
*/
|
||||
@interface WEPopoverController : NSObject<WETouchableViewDelegate> {
|
||||
UIViewController *contentViewController;
|
||||
UIView *view;
|
||||
UIView *parentView;
|
||||
WETouchableView *backgroundView;
|
||||
|
||||
BOOL popoverVisible;
|
||||
UIPopoverArrowDirection popoverArrowDirection;
|
||||
id <WEPopoverControllerDelegate> delegate;
|
||||
CGSize popoverContentSize;
|
||||
WEPopoverContainerViewProperties *containerViewProperties;
|
||||
id <NSObject> context;
|
||||
NSArray *passthroughViews;
|
||||
}
|
||||
|
||||
@property(nonatomic, retain) UIViewController *contentViewController;
|
||||
|
||||
@property (nonatomic, readonly) UIView *view;
|
||||
@property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;
|
||||
@property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;
|
||||
@property (nonatomic, assign) id <WEPopoverControllerDelegate> delegate;
|
||||
@property (nonatomic, assign) CGSize popoverContentSize;
|
||||
@property (nonatomic, retain) WEPopoverContainerViewProperties *containerViewProperties;
|
||||
@property (nonatomic, retain) id <NSObject> context;
|
||||
@property (nonatomic, assign) UIView *parentView;
|
||||
@property (nonatomic, copy) NSArray *passthroughViews;
|
||||
|
||||
- (id)initWithContentViewController:(UIViewController *)theContentViewController;
|
||||
|
||||
- (void)dismissPopoverAnimated:(BOOL)animated;
|
||||
|
||||
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated;
|
||||
|
||||
- (void)presentPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)view
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated;
|
||||
|
||||
- (void)repositionPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)view
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections;
|
||||
|
||||
- (void)repositionPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)view
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated;
|
||||
|
||||
@end
|
|
@ -1,377 +0,0 @@
|
|||
//
|
||||
// WEPopoverController.m
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 02/09/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WEPopoverController.h"
|
||||
#import "WEPopoverParentView.h"
|
||||
#import "UIBarButtonItem+WEPopover.h"
|
||||
|
||||
#define FADE_DURATION 0.3
|
||||
|
||||
@interface WEPopoverController(Private)
|
||||
|
||||
- (UIView *)keyView;
|
||||
- (void)updateBackgroundPassthroughViews;
|
||||
- (void)setView:(UIView *)v;
|
||||
- (CGRect)displayAreaForView:(UIView *)theView;
|
||||
- (WEPopoverContainerViewProperties *)defaultContainerViewProperties;
|
||||
- (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation WEPopoverController
|
||||
|
||||
@synthesize contentViewController;
|
||||
@synthesize popoverContentSize;
|
||||
@synthesize popoverVisible;
|
||||
@synthesize popoverArrowDirection;
|
||||
@synthesize delegate;
|
||||
@synthesize view;
|
||||
@synthesize parentView;
|
||||
@synthesize containerViewProperties;
|
||||
@synthesize context;
|
||||
@synthesize passthroughViews;
|
||||
|
||||
- (id)init {
|
||||
if ((self = [super init])) {
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithContentViewController:(UIViewController *)viewController {
|
||||
if ((self = [self init])) {
|
||||
self.contentViewController = viewController;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self dismissPopoverAnimated:NO];
|
||||
[contentViewController release];
|
||||
[containerViewProperties release];
|
||||
[passthroughViews release];
|
||||
self.context = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setContentViewController:(UIViewController *)vc {
|
||||
if (vc != contentViewController) {
|
||||
[contentViewController release];
|
||||
contentViewController = [vc retain];
|
||||
popoverContentSize = CGSizeZero;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)forwardAppearanceMethods {
|
||||
return YES;
|
||||
return ![contentViewController respondsToSelector:@selector(shouldAutomaticallyForwardAppearanceMethods)];
|
||||
}
|
||||
|
||||
//Overridden setter to copy the passthroughViews to the background view if it exists already
|
||||
- (void)setPassthroughViews:(NSArray *)array {
|
||||
[passthroughViews release];
|
||||
passthroughViews = nil;
|
||||
if (array) {
|
||||
passthroughViews = [[NSArray alloc] initWithArray:array];
|
||||
}
|
||||
[self updateBackgroundPassthroughViews];
|
||||
}
|
||||
|
||||
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)theContext {
|
||||
|
||||
if ([animationID isEqual:@"FadeIn"]) {
|
||||
self.view.userInteractionEnabled = YES;
|
||||
popoverVisible = YES;
|
||||
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewDidAppear:YES];
|
||||
}
|
||||
} else if ([animationID isEqual:@"FadeOut"]) {
|
||||
popoverVisible = NO;
|
||||
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewDidDisappear:YES];
|
||||
}
|
||||
[self.view removeFromSuperview];
|
||||
self.view = nil;
|
||||
[backgroundView removeFromSuperview];
|
||||
[backgroundView release];
|
||||
backgroundView = nil;
|
||||
|
||||
BOOL userInitiatedDismissal = [(NSNumber *)theContext boolValue];
|
||||
|
||||
if (userInitiatedDismissal) {
|
||||
//Only send message to delegate in case the user initiated this event, which is if he touched outside the view
|
||||
[delegate popoverControllerDidDismissPopover:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dismissPopoverAnimated:(BOOL)animated {
|
||||
|
||||
[self dismissPopoverAnimated:animated userInitiated:NO];
|
||||
}
|
||||
|
||||
- (void)presentPopoverFromBarButtonItem:(UIBarButtonItem *)item
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated {
|
||||
|
||||
UIView *v = [self keyView];
|
||||
CGRect rect = [item frameInView:v];
|
||||
|
||||
return [self presentPopoverFromRect:rect inView:v permittedArrowDirections:arrowDirections animated:animated];
|
||||
}
|
||||
|
||||
- (void)presentPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)theView
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated {
|
||||
|
||||
|
||||
[self dismissPopoverAnimated:NO];
|
||||
|
||||
//First force a load view for the contentViewController so the popoverContentSize is properly initialized
|
||||
[contentViewController view];
|
||||
|
||||
if (CGSizeEqualToSize(popoverContentSize, CGSizeZero)) {
|
||||
popoverContentSize = contentViewController.preferredContentSize;
|
||||
}
|
||||
|
||||
CGRect displayArea = [self displayAreaForView:theView];
|
||||
|
||||
WEPopoverContainerViewProperties *props = self.containerViewProperties ? self.containerViewProperties : [self defaultContainerViewProperties];
|
||||
WEPopoverContainerView *containerView = [[[WEPopoverContainerView alloc] initWithSize:self.popoverContentSize anchorRect:rect displayArea:displayArea permittedArrowDirections:arrowDirections properties:props] autorelease];
|
||||
popoverArrowDirection = containerView.arrowDirection;
|
||||
|
||||
UIView *keyView = self.keyView;
|
||||
|
||||
backgroundView = [[WETouchableView alloc] initWithFrame:keyView.bounds];
|
||||
backgroundView.contentMode = UIViewContentModeScaleToFill;
|
||||
backgroundView.autoresizingMask = ( UIViewAutoresizingFlexibleLeftMargin |
|
||||
UIViewAutoresizingFlexibleWidth |
|
||||
UIViewAutoresizingFlexibleRightMargin |
|
||||
UIViewAutoresizingFlexibleTopMargin |
|
||||
UIViewAutoresizingFlexibleHeight |
|
||||
UIViewAutoresizingFlexibleBottomMargin);
|
||||
backgroundView.backgroundColor = [UIColor clearColor];
|
||||
backgroundView.delegate = self;
|
||||
|
||||
[keyView addSubview:backgroundView];
|
||||
|
||||
containerView.frame = [theView convertRect:containerView.frame toView:backgroundView];
|
||||
|
||||
[backgroundView addSubview:containerView];
|
||||
|
||||
containerView.contentView = contentViewController.view;
|
||||
containerView.autoresizingMask = ( UIViewAutoresizingFlexibleLeftMargin |
|
||||
UIViewAutoresizingFlexibleRightMargin);
|
||||
|
||||
self.view = containerView;
|
||||
[self updateBackgroundPassthroughViews];
|
||||
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewWillAppear:animated];
|
||||
}
|
||||
[self.view becomeFirstResponder];
|
||||
popoverVisible = YES;
|
||||
if (animated) {
|
||||
self.view.alpha = 0.0;
|
||||
|
||||
[UIView animateWithDuration:FADE_DURATION
|
||||
delay:0.0
|
||||
options:UIViewAnimationCurveLinear
|
||||
animations:^{
|
||||
|
||||
self.view.alpha = 1.0;
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
|
||||
[self animationDidStop:@"FadeIn" finished:[NSNumber numberWithBool:finished] context:nil];
|
||||
}];
|
||||
|
||||
} else {
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewDidAppear:animated];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)repositionPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)theView
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
{
|
||||
|
||||
[self repositionPopoverFromRect:rect
|
||||
inView:theView
|
||||
permittedArrowDirections:arrowDirections
|
||||
animated:NO];
|
||||
}
|
||||
|
||||
- (void)repositionPopoverFromRect:(CGRect)rect
|
||||
inView:(UIView *)theView
|
||||
permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections
|
||||
animated:(BOOL)animated {
|
||||
|
||||
if (animated) {
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:FADE_DURATION];
|
||||
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
|
||||
}
|
||||
|
||||
if (CGSizeEqualToSize(popoverContentSize, CGSizeZero)) {
|
||||
popoverContentSize = contentViewController.preferredContentSize;
|
||||
}
|
||||
|
||||
CGRect displayArea = [self displayAreaForView:theView];
|
||||
WEPopoverContainerView *containerView = (WEPopoverContainerView *)self.view;
|
||||
[containerView updatePositionWithSize:self.popoverContentSize
|
||||
anchorRect:rect
|
||||
displayArea:displayArea
|
||||
permittedArrowDirections:arrowDirections];
|
||||
|
||||
popoverArrowDirection = containerView.arrowDirection;
|
||||
containerView.frame = [theView convertRect:containerView.frame toView:backgroundView];
|
||||
|
||||
if (animated) {
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WETouchableViewDelegate implementation
|
||||
|
||||
- (void)viewWasTouched:(WETouchableView *)view {
|
||||
if (popoverVisible) {
|
||||
if (!delegate || [delegate popoverControllerShouldDismissPopover:self]) {
|
||||
[self dismissPopoverAnimated:YES userInitiated:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isPopoverVisible {
|
||||
if (!popoverVisible) {
|
||||
return NO;
|
||||
}
|
||||
UIView *sv = self.view;
|
||||
BOOL foundWindowAsSuperView = NO;
|
||||
while ((sv = sv.superview) != nil) {
|
||||
if ([sv isKindOfClass:[UIWindow class]]) {
|
||||
foundWindowAsSuperView = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return foundWindowAsSuperView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation WEPopoverController(Private)
|
||||
|
||||
- (UIView *)keyView {
|
||||
if (self.parentView) {
|
||||
return self.parentView;
|
||||
} else {
|
||||
UIWindow *w = [[UIApplication sharedApplication] keyWindow];
|
||||
if (w.subviews.count > 0) {
|
||||
return [w.subviews objectAtIndex:0];
|
||||
} else {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setView:(UIView *)v {
|
||||
if (view != v) {
|
||||
[view release];
|
||||
view = [v retain];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateBackgroundPassthroughViews {
|
||||
backgroundView.passthroughViews = passthroughViews;
|
||||
}
|
||||
|
||||
|
||||
- (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated {
|
||||
if (self.view) {
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewWillDisappear:animated];
|
||||
}
|
||||
popoverVisible = NO;
|
||||
[self.view resignFirstResponder];
|
||||
if (animated) {
|
||||
self.view.userInteractionEnabled = NO;
|
||||
|
||||
[UIView animateWithDuration:FADE_DURATION
|
||||
delay:0.0
|
||||
options:UIViewAnimationCurveLinear
|
||||
animations:^{
|
||||
|
||||
self.view.alpha = 0.0;
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
|
||||
[self animationDidStop:@"FadeOut" finished:[NSNumber numberWithBool:finished] context:[NSNumber numberWithBool:userInitiated]];
|
||||
}];
|
||||
|
||||
|
||||
} else {
|
||||
if ([self forwardAppearanceMethods]) {
|
||||
[contentViewController viewDidDisappear:animated];
|
||||
}
|
||||
[self.view removeFromSuperview];
|
||||
self.view = nil;
|
||||
[backgroundView removeFromSuperview];
|
||||
[backgroundView release];
|
||||
backgroundView = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (CGRect)displayAreaForView:(UIView *)theView {
|
||||
CGRect displayArea = CGRectZero;
|
||||
if ([theView conformsToProtocol:@protocol(WEPopoverParentView)] && [theView respondsToSelector:@selector(displayAreaForPopover)]) {
|
||||
displayArea = [(id <WEPopoverParentView>)theView displayAreaForPopover];
|
||||
} else {
|
||||
UIView *keyView = [self keyView];
|
||||
displayArea = [keyView convertRect:keyView.bounds toView:theView];
|
||||
}
|
||||
return displayArea;
|
||||
}
|
||||
|
||||
//Enable to use the simple popover style
|
||||
- (WEPopoverContainerViewProperties *)defaultContainerViewProperties {
|
||||
WEPopoverContainerViewProperties *ret = [[WEPopoverContainerViewProperties new] autorelease];
|
||||
|
||||
CGSize imageSize = CGSizeMake(30.0f, 30.0f);
|
||||
NSString *bgImageName = @"popoverBgSimple.png";
|
||||
CGFloat bgMargin = 6.0;
|
||||
CGFloat contentMargin = 2.0;
|
||||
|
||||
ret.leftBgMargin = bgMargin;
|
||||
ret.rightBgMargin = bgMargin;
|
||||
ret.topBgMargin = bgMargin;
|
||||
ret.bottomBgMargin = bgMargin;
|
||||
ret.leftBgCapSize = imageSize.width/2;
|
||||
ret.topBgCapSize = imageSize.height/2;
|
||||
ret.bgImageName = bgImageName;
|
||||
ret.leftContentMargin = contentMargin;
|
||||
ret.rightContentMargin = contentMargin;
|
||||
ret.topContentMargin = contentMargin;
|
||||
ret.bottomContentMargin = contentMargin;
|
||||
ret.arrowMargin = 1.0;
|
||||
|
||||
ret.upArrowImageName = @"popoverArrowUpSimple.png";
|
||||
ret.downArrowImageName = @"popoverArrowDownSimple.png";
|
||||
ret.leftArrowImageName = @"popoverArrowLeftSimple.png";
|
||||
ret.rightArrowImageName = @"popoverArrowRightSimple.png";
|
||||
return ret;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
* WEPopoverParentView.h
|
||||
* WEPopover
|
||||
*
|
||||
* Created by Werner Altewischer on 02/09/10.
|
||||
* Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@protocol WEPopoverParentView
|
||||
|
||||
@optional
|
||||
- (CGRect)displayAreaForPopover;
|
||||
|
||||
@end
|
|
@ -1,37 +0,0 @@
|
|||
//
|
||||
// WETouchableView.h
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 12/21/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class WETouchableView;
|
||||
|
||||
/**
|
||||
* @brief delegate to receive touch events
|
||||
*/
|
||||
@protocol WETouchableViewDelegate<NSObject>
|
||||
|
||||
- (void)viewWasTouched:(WETouchableView *)view;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* @brief View that can handle touch events and/or disable touch forwording to child views
|
||||
*/
|
||||
@interface WETouchableView : UIView {
|
||||
BOOL touchForwardingDisabled;
|
||||
id <WETouchableViewDelegate> delegate;
|
||||
NSArray *passthroughViews;
|
||||
BOOL testHits;
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) BOOL touchForwardingDisabled;
|
||||
@property (nonatomic, assign) id <WETouchableViewDelegate> delegate;
|
||||
@property (nonatomic, copy) NSArray *passthroughViews;
|
||||
|
||||
@end
|
|
@ -1,70 +0,0 @@
|
|||
//
|
||||
// WETouchableView.m
|
||||
// WEPopover
|
||||
//
|
||||
// Created by Werner Altewischer on 12/21/10.
|
||||
// Copyright 2010 Werner IT Consultancy. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WETouchableView.h"
|
||||
|
||||
@interface WETouchableView(Private)
|
||||
|
||||
- (BOOL)isPassthroughView:(UIView *)v;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WETouchableView
|
||||
|
||||
@synthesize touchForwardingDisabled, delegate, passthroughViews;
|
||||
|
||||
- (void)dealloc {
|
||||
[passthroughViews release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
||||
if (testHits) {
|
||||
return nil;
|
||||
} else if (touchForwardingDisabled) {
|
||||
return self;
|
||||
} else {
|
||||
UIView *hitView = [super hitTest:point withEvent:event];
|
||||
|
||||
if (hitView == self) {
|
||||
//Test whether any of the passthrough views would handle this touch
|
||||
testHits = YES;
|
||||
UIView *superHitView = [self.superview hitTest:point withEvent:event];
|
||||
testHits = NO;
|
||||
|
||||
if ([self isPassthroughView:superHitView]) {
|
||||
hitView = superHitView;
|
||||
}
|
||||
}
|
||||
|
||||
return hitView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
[self.delegate viewWasTouched:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WETouchableView(Private)
|
||||
|
||||
- (BOOL)isPassthroughView:(UIView *)v {
|
||||
|
||||
if (v == nil) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([passthroughViews containsObject:v]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [self isPassthroughView:v.superview];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Add table
Reference in a new issue