Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Classes/Popover/WEPopoverContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
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, strong) NSString *bgImageName;
@property(nonatomic, strong) NSString *upArrowImageName;
@property(nonatomic, strong) NSString *downArrowImageName;
@property(nonatomic, strong) NSString *leftArrowImageName;
@property(nonatomic, strong) NSString *rightArrowImageName;
@property(nonatomic, assign) CGFloat leftBgMargin;
@property(nonatomic, assign) CGFloat rightBgMargin;
@property(nonatomic, assign) CGFloat topBgMargin;
Expand Down Expand Up @@ -77,7 +77,7 @@
/**
* @brief The content view being displayed.
*/
@property (nonatomic, retain) UIView *contentView;
@property (nonatomic, strong) UIView *contentView;

/**
* @brief Initializes the position of the popover with a size, anchor rect, display area and permitted arrow directions and optionally the properties.
Expand Down
31 changes: 7 additions & 24 deletions Classes/Popover/WEPopoverContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ @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

Expand Down Expand Up @@ -52,21 +44,14 @@ - (id)initWithSize:(CGSize)theSize
[self initFrame];
self.backgroundColor = [UIColor clearColor];
UIImage *theImage = [UIImage imageNamed:properties.bgImageName];
bgImage = [[theImage stretchableImageWithLeftCapWidth:properties.leftBgCapSize topCapHeight:properties.topBgCapSize] retain];
bgImage = [theImage stretchableImageWithLeftCapWidth:properties.leftBgCapSize topCapHeight:properties.topBgCapSize];

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];
Expand Down Expand Up @@ -108,8 +93,7 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

- (void)setContentView:(UIView *)v {
if (v != contentView) {
[contentView release];
contentView = [v retain];
contentView = v;
contentView.frame = self.contentRect;
[self addSubview:contentView];
}
Expand Down Expand Up @@ -146,8 +130,7 @@ - (CGRect)contentRect {

- (void)setProperties:(WEPopoverContainerViewProperties *)props {
if (properties != props) {
[properties release];
properties = [props retain];
properties = props;
}
}

Expand Down Expand Up @@ -348,16 +331,16 @@ - (void)determineGeometryForSize:(CGSize)theSize anchorRect:(CGRect)anchorRect d

switch (arrowDirection) {
case UIPopoverArrowDirectionUp:
arrowImage = [upArrowImage retain];
arrowImage = upArrowImage;
break;
case UIPopoverArrowDirectionDown:
arrowImage = [downArrowImage retain];
arrowImage = downArrowImage;
break;
case UIPopoverArrowDirectionLeft:
arrowImage = [leftArrowImage retain];
arrowImage = leftArrowImage;
break;
case UIPopoverArrowDirectionRight:
arrowImage = [rightArrowImage retain];
arrowImage = rightArrowImage;
break;
default:
break;
Expand Down
18 changes: 10 additions & 8 deletions Classes/Popover/WEPopoverController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

@protocol WEPopoverControllerDelegate<NSObject>

@optional

- (void)popoverControllerDidDismissPopover:(WEPopoverController *)popoverController;
- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)popoverController;

Expand All @@ -26,28 +28,28 @@
@interface WEPopoverController : NSObject<WETouchableViewDelegate> {
UIViewController *contentViewController;
UIView *view;
UIView *parentView;
UIView __weak *parentView;
WETouchableView *backgroundView;

BOOL popoverVisible;
UIPopoverArrowDirection popoverArrowDirection;
id <WEPopoverControllerDelegate> delegate;
id <WEPopoverControllerDelegate> __weak delegate;
CGSize popoverContentSize;
WEPopoverContainerViewProperties *containerViewProperties;
id <NSObject> context;
NSArray *passthroughViews;
}

@property(nonatomic, retain) UIViewController *contentViewController;
@property(nonatomic, strong) UIViewController *contentViewController;

@property (nonatomic, readonly) UIView *view;
@property (nonatomic, strong, readonly) UIView *view;
@property (nonatomic, readonly, getter=isPopoverVisible) BOOL popoverVisible;
@property (nonatomic, readonly) UIPopoverArrowDirection popoverArrowDirection;
@property (nonatomic, assign) id <WEPopoverControllerDelegate> delegate;
@property (nonatomic, weak) 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, strong) WEPopoverContainerViewProperties *containerViewProperties;
@property (nonatomic, strong) id <NSObject> context;
@property (nonatomic, weak) UIView *parentView;
@property (nonatomic, copy) NSArray *passthroughViews;

- (id)initWithContentViewController:(UIViewController *)theContentViewController;
Expand Down
35 changes: 16 additions & 19 deletions Classes/Popover/WEPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ - (id)initWithContentViewController:(UIViewController *)viewController {

- (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];
contentViewController = vc;
popoverContentSize = CGSizeZero;
}
}
Expand All @@ -73,7 +67,6 @@ - (BOOL)forwardAppearanceMethods {

//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];
Expand All @@ -99,14 +92,16 @@ - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished c
[self.view removeFromSuperview];
self.view = nil;
[backgroundView removeFromSuperview];
[backgroundView release];
backgroundView = nil;

BOOL userInitiatedDismissal = [(NSNumber *)theContext boolValue];
BOOL userInitiatedDismissal = [(__bridge 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];
if(delegate != nil && [delegate conformsToProtocol:@protocol(WEPopoverControllerDelegate)] &&
[delegate respondsToSelector:@selector(popoverControllerDidDismissPopover:)]) {
[delegate popoverControllerDidDismissPopover:self];
}
}
}
}
Expand Down Expand Up @@ -144,7 +139,7 @@ - (void)presentPopoverFromRect:(CGRect)rect
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];
WEPopoverContainerView *containerView = [[WEPopoverContainerView alloc] initWithSize:self.popoverContentSize anchorRect:rect displayArea:displayArea permittedArrowDirections:arrowDirections properties:props];
popoverArrowDirection = containerView.arrowDirection;

UIView *keyView = self.keyView;
Expand Down Expand Up @@ -246,9 +241,13 @@ - (void)repositionPopoverFromRect:(CGRect)rect

- (void)viewWasTouched:(WETouchableView *)view {
if (popoverVisible) {
if (!delegate || [delegate popoverControllerShouldDismissPopover:self]) {
[self dismissPopoverAnimated:YES userInitiated:YES];
BOOL shouldDismiss = YES;
if(delegate != nil && [delegate conformsToProtocol:@protocol(WEPopoverControllerDelegate)] &&
[delegate respondsToSelector:@selector(popoverControllerShouldDismissPopover:)]) {
shouldDismiss = [delegate popoverControllerShouldDismissPopover:self];
}
if(shouldDismiss)
[self dismissPopoverAnimated:YES userInitiated:YES];
}
}

Expand Down Expand Up @@ -287,8 +286,7 @@ - (UIView *)keyView {

- (void)setView:(UIView *)v {
if (view != v) {
[view release];
view = [v retain];
view = v;
}
}

Expand Down Expand Up @@ -316,7 +314,7 @@ - (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated

} completion:^(BOOL finished) {

[self animationDidStop:@"FadeOut" finished:[NSNumber numberWithBool:finished] context:[NSNumber numberWithBool:userInitiated]];
[self animationDidStop:@"FadeOut" finished:[NSNumber numberWithBool:finished] context:(__bridge void *)([NSNumber numberWithBool:userInitiated])];
}];


Expand All @@ -327,7 +325,6 @@ - (void)dismissPopoverAnimated:(BOOL)animated userInitiated:(BOOL)userInitiated
[self.view removeFromSuperview];
self.view = nil;
[backgroundView removeFromSuperview];
[backgroundView release];
backgroundView = nil;
}
}
Expand All @@ -346,7 +343,7 @@ - (CGRect)displayAreaForView:(UIView *)theView {

//Enable to use the simple popover style
- (WEPopoverContainerViewProperties *)defaultContainerViewProperties {
WEPopoverContainerViewProperties *ret = [[WEPopoverContainerViewProperties new] autorelease];
WEPopoverContainerViewProperties *ret = [WEPopoverContainerViewProperties new];

CGSize imageSize = CGSizeMake(30.0f, 30.0f);
NSString *bgImageName = @"popoverBgSimple.png";
Expand Down
4 changes: 2 additions & 2 deletions Classes/Popover/WETouchableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
*/
@interface WETouchableView : UIView {
BOOL touchForwardingDisabled;
id <WETouchableViewDelegate> delegate;
id <WETouchableViewDelegate> __weak delegate;
NSArray *passthroughViews;
BOOL testHits;
}

@property (nonatomic, assign) BOOL touchForwardingDisabled;
@property (nonatomic, assign) id <WETouchableViewDelegate> delegate;
@property (nonatomic, weak) id <WETouchableViewDelegate> delegate;
@property (nonatomic, copy) NSArray *passthroughViews;

@end
4 changes: 0 additions & 4 deletions Classes/Popover/WETouchableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ @implementation WETouchableView

@synthesize touchForwardingDisabled, delegate, passthroughViews;

- (void)dealloc {
[passthroughViews release];
[super dealloc];
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (testHits) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/WEPopoverAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
UINavigationController *navController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
@property (nonatomic, strong) IBOutlet UIWindow *window;
@property (nonatomic, strong) IBOutlet UINavigationController *navController;

@end

11 changes: 5 additions & 6 deletions Classes/WEPopoverAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Override point for customization after application launch.

// Add the view controller's view to the window and display.
[window addSubview:navController.view];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 4.0) {
[window addSubview:navController.view];
} else {
[window setRootViewController:navController];
}
[window makeKeyAndVisible];

return YES;
Expand Down Expand Up @@ -78,11 +82,6 @@ Free up as much memory as possible by purging cached data objects that can be re
}


- (void)dealloc {
[navController release];
[window release];
[super dealloc];
}


@end
5 changes: 1 addition & 4 deletions Classes/WEPopoverContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

// Configure the cell...
Expand Down Expand Up @@ -121,9 +121,6 @@ - (void)viewDidUnload {
}


- (void)dealloc {
[super dealloc];
}


@end
Expand Down
2 changes: 1 addition & 1 deletion Classes/WEPopoverTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Class popoverClass;
}

@property (nonatomic, retain) WEPopoverController *popoverController;
@property (nonatomic, strong) WEPopoverController *popoverController;

- (IBAction)showPopover:(id)sender;

Expand Down
Loading