Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Greatly improve the hit target region of the comment accessory view
Browse files Browse the repository at this point in the history
  • Loading branch information
rbruels committed Dec 20, 2010
1 parent de310a9 commit e39a80a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Classes/ViewControllers/SubredditTableViewDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ - (id)initWithController:(TTTableViewController*)controller
return self;
}

- (void)virtualAccessoryViewTapped:(id)sender
{
[self.controller.dataSource accessoryViewTapped:sender];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
[super scrollViewDidEndDecelerating:scrollView];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Views/CommentAccessoryView.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ - (id)initWithFrame:(CGRect)frame
{
self.backgroundColor = [UIColor whiteColor];
self.opaque = YES;

self.contentMode = UIViewContentModeCenter;
[self setBackgroundImage:[[UIImage imageNamed:@"commentBubble.png"] stretchableImageWithLeftCapWidth:20.0 topCapHeight:0.0] forState:UIControlStateNormal];

self.titleEdgeInsets = UIEdgeInsetsMake(0.0, 1.0, 6.0, 0.0);
Expand Down
1 change: 1 addition & 0 deletions Classes/Views/StoryCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
UILabel *storyDescriptionView;
UILabel *secondaryDescriptionView;
TTImageView *storyImage;
UIButton *virtualAccessory;
}

@property (nonatomic,retain) Story *story;
Expand Down
19 changes: 19 additions & 0 deletions Classes/Views/StoryCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,32 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
next:[TTContentStyle styleWithNext:nil]]];

[[self contentView] addSubview:storyImage];

virtualAccessory = [[UIButton alloc] initWithFrame:CGRectZero];
virtualAccessory.adjustsImageWhenHighlighted = NO;
[virtualAccessory addTarget:self action:@selector(virtualAccessoryTapped:) forControlEvents:UIControlEventTouchUpInside];
virtualAccessory.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleLeftMargin;
virtualAccessory.backgroundColor = [UIColor clearColor];
[self addSubview:virtualAccessory];
}

return self;
}

- (void)virtualAccessoryTapped:(id)sender
{
UITableView *enclosingTable = (UITableView *)self.superview;
if(self.accessoryView && enclosingTable.delegate && [enclosingTable.delegate respondsToSelector:@selector(virtualAccessoryViewTapped:)])
{
[enclosingTable.delegate virtualAccessoryViewTapped:self.accessoryView];
}
}

- (void)layoutSubviews
{
[super layoutSubviews];

CGRect cellRect = self.bounds;
CGRect contentRect = self.contentView.bounds;
CGRect labelRect = contentRect;

Expand All @@ -112,6 +129,8 @@ - (void)layoutSubviews

//BOOL showThumbnails = [[NSUserDefaults standardUserDefaults] boolForKey:@"showStoryThumbnails"];

virtualAccessory.frame = CGRectMake(cellRect.size.width-40, 0, 40, cellRect.size.height);

if ([storyImage isHidden])
{
//[storyImage setHidden:YES];
Expand Down

0 comments on commit e39a80a

Please sign in to comment.