Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

I add a delegate to it. For my thanks. That's all I can make this project looks more well.. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

#import "JGScrollableTableViewCell.h"

@protocol IPQJGScrollableTableViewCellDelegate <NSObject>
@optional
-(void)swipTableViewCellLeftButton:(JGScrollableTableViewCell*)swipeTableViewCell;
-(void)swipTableViewCellRightButton:(JGScrollableTableViewCell*)swipeTableViewCell;
@end

@interface JGExampleScrollableTableViewCell : JGScrollableTableViewCell

- (void)setGrabberVisible:(BOOL)visible;

@property (nonatomic, assign) id <IPQJGScrollableTableViewCellDelegate> ipqDelegate;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus

[moreView setTitle:@"Sample" forState:UIControlStateNormal];

[actionView addTarget:self action:@selector(actionRightButton) forControlEvents:UIControlEventTouchUpInside];//add left action button for pressed

moreView.frame = CGRectMake(0.0f, 0.0f, 80.0f, 0.0f); //width is the only frame parameter that needs to be set on the option view
moreView.autoresizingMask = UIViewAutoresizingFlexibleHeight;


UIView *optionView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 160.0f, 0.0f)];

[moreView addTarget:self action:@selector(actionLeftButton) forControlEvents:UIControlEventTouchUpInside];//add right button for pressed

[optionView addSubview:moreView];
[optionView addSubview:actionView];
Expand Down Expand Up @@ -67,7 +71,16 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
}
return self;
}

-(void)actionLeftButton{
if ([self.ipqDelegate respondsToSelector:@selector(swipTableViewCellLeftButton:)]) {
[self.ipqDelegate swipTableViewCellLeftButton:self];
}
}
-(void)actionRightButton{
if ([self.ipqDelegate respondsToSelector:@selector(swipTableViewCellRightButton:)]) {
[self.ipqDelegate swipTableViewCellRightButton:self];
}
}
- (void)setGrabberVisible:(BOOL)visible {
if (visible) {
UIView *grabber = [[UIView alloc] initWithFrame:(CGRect){CGPointZero, {20.0f, 35.0f}}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#import "JGScrollableTableViewCellAccessoryButton.h"

@interface JGTestViewController () <JGScrollableTableViewCellDelegate> {
@interface JGTestViewController () <JGScrollableTableViewCellDelegate,IPQJGScrollableTableViewCellDelegate> {
NSIndexPath *_openedIndexPath;
}

Expand All @@ -32,6 +32,18 @@ - (instancetype)initWithStyle:(UITableViewStyle)style {
return self;
}

#pragma mark - IPQJGScrollableTableViewCellDelegate
-(void)swipTableViewCellLeftButton:(JGScrollableTableViewCell*)swipeTableViewCell{
NSIndexPath *indexPath = [self.tableView indexPathForCell:swipeTableViewCell];
NSLog(@"indexpath = %d",indexPath.row);
NSLog(@"Left Button is pressed");
}
-(void)swipTableViewCellRightButton:(JGScrollableTableViewCell*)swipeTableViewCell{
NSIndexPath *indexPath = [self.tableView indexPathForCell:swipeTableViewCell];
NSLog(@"indexpath = %d",indexPath.row);
NSLog(@"Right Button is pressed");
}

#pragma mark - JGScrollableTableViewCellDelegate

- (void)cellDidBeginScrolling:(JGScrollableTableViewCell *)cell {
Expand Down Expand Up @@ -76,6 +88,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N

cell.scrollDelegate = self;

cell.ipqDelegate = self;

[cell setOptionViewVisible:[_openedIndexPath isEqual:indexPath]];

return cell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
// JGExampleScrollableTableViewCell.h
// JGScrollableTableViewCell Basic
//
// Add Delegate by ipqhjjybj
// @date 2014.02.18
// Created by Jonas Gessner on 21.12.13.
// Copyright (c) 2013 Jonas Gessner. All rights reserved.
//

#import "JGScrollableTableViewCell.h"

@protocol IPQJGScrollableTableViewCellDelegate <NSObject>
@optional
-(void)swipTableViewCellLeftButton:(JGScrollableTableViewCell*)swipeTableViewCell;
-(void)swipTableViewCellRightButton:(JGScrollableTableViewCell*)swipeTableViewCell;
@end

@interface JGExampleScrollableTableViewCell : JGScrollableTableViewCell

- (void)setGrabberVisible:(BOOL)visible;

@property (nonatomic, assign) id <IPQJGScrollableTableViewCellDelegate> ipqDelegate;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus

[actionView setTitle:@"Sample" forState:UIControlStateNormal];

[actionView addTarget:self action:@selector(actionRightButton) forControlEvents:UIControlEventTouchUpInside];//add left action button for pressed

actionView.frame = CGRectMake(80.0f, 0.0f, 80.0f, 0.0f); //width is the only frame parameter that needs to be set on the option view
actionView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

Expand All @@ -41,14 +43,25 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus

UIView *optionView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 160.0f, 0.0f)];

[moreView addTarget:self action:@selector(actionLeftButton) forControlEvents:UIControlEventTouchUpInside];//add right button for pressed

[optionView addSubview:moreView];
[optionView addSubview:actionView];

[self setOptionView:optionView side:JGScrollableTableViewCellSideRight];
}
return self;
}

-(void)actionLeftButton{
if ([self.ipqDelegate respondsToSelector:@selector(swipTableViewCellLeftButton:)]) {
[self.ipqDelegate swipTableViewCellLeftButton:self];
}
}
-(void)actionRightButton{
if ([self.ipqDelegate respondsToSelector:@selector(swipTableViewCellRightButton:)]) {
[self.ipqDelegate swipTableViewCellRightButton:self];
}
}
- (void)setGrabberVisible:(BOOL)visible {
if (visible) {
UIView *grabber = [[UIView alloc] initWithFrame:(CGRect){CGPointZero, {20.0f, 35.0f}}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#import "JGScrollableTableViewCellAccessoryButton.h"

@interface JGTestViewController () <JGScrollableTableViewCellDelegate> {
@interface JGTestViewController () <JGScrollableTableViewCellDelegate,IPQJGScrollableTableViewCellDelegate> {
NSIndexPath *_openedIndexPath;
BOOL _left;
}
Expand Down Expand Up @@ -44,6 +44,17 @@ - (void)switched:(UISwitch *)sender {
[self.tableView reloadData];
}

#pragma mark - IPQJGScrollableTableViewCellDelegate
-(void)swipTableViewCellLeftButton:(JGScrollableTableViewCell*)swipeTableViewCell{
NSIndexPath *indexPath = [self.tableView indexPathForCell:swipeTableViewCell];
NSLog(@"indexpath = %d",indexPath.row);
NSLog(@"Left Button is pressed");
}
-(void)swipTableViewCellRightButton:(JGScrollableTableViewCell*)swipeTableViewCell{
NSIndexPath *indexPath = [self.tableView indexPathForCell:swipeTableViewCell];
NSLog(@"indexpath = %d",indexPath.row);
NSLog(@"Right Button is pressed");
}

#pragma mark - JGScrollableTableViewCellDelegate

Expand Down Expand Up @@ -90,6 +101,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell setOptionView:cell.optionView side:(_left ? JGScrollableTableViewCellSideLeft : JGScrollableTableViewCellSideRight)];

cell.scrollDelegate = self;
cell.ipqDelegate = self;

[cell setOptionViewVisible:[_openedIndexPath isEqual:indexPath]];

Expand Down