This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
forked from JonasGessner/JGScrollableTableViewCell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonas Gessner
committed
Nov 4, 2013
1 parent
e7e25d1
commit 4d84a04
Showing
14 changed files
with
668 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Xcode | ||
.DS_Store | ||
*/build/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
profile | ||
*.moved-aside | ||
DerivedData | ||
.idea/ | ||
*.hmap | ||
*.xccheckout |
184 changes: 30 additions & 154 deletions
184
JGScrollableTableViewCell Examples.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// JGTextViewController.h | ||
// JGScrollableTableViewCell Examples | ||
// | ||
// Created by Jonas Gessner on 03.11.13. | ||
// Copyright (c) 2013 Jonas Gessner. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface JGTextViewController : UITableViewController | ||
|
||
@end |
101 changes: 101 additions & 0 deletions
101
JGScrollableTableViewCell Examples/JGTextViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// JGTextViewController.m | ||
// JGScrollableTableViewCell Examples | ||
// | ||
// Created by Jonas Gessner on 03.11.13. | ||
// Copyright (c) 2013 Jonas Gessner. All rights reserved. | ||
// | ||
|
||
#import "JGTextViewController.h" | ||
|
||
#import "JGScrollableTableViewCell.h" | ||
#import "JGScrollableTableViewCellAccessoryButton.h" | ||
|
||
@interface JGTextViewController () <JGScrollableTableViewCellDelegate> { | ||
NSIndexPath *_openedIndexPath; | ||
} | ||
|
||
@end | ||
|
||
@implementation JGTextViewController | ||
|
||
- (instancetype)initWithStyle:(UITableViewStyle)style { | ||
self = [super initWithStyle:style]; | ||
if (self) { | ||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | ||
|
||
[self.tableView registerClass:[JGScrollableTableViewCell class] forCellReuseIdentifier:@"ScrollCell"]; | ||
} | ||
return self; | ||
} | ||
|
||
|
||
|
||
#pragma mark - JGScrollableTableViewCellDelegate | ||
|
||
- (void)cellDidBeginScrolling:(JGScrollableTableViewCell *)cell { | ||
[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell]; | ||
} | ||
|
||
- (void)cellDidScroll:(JGScrollableTableViewCell *)cell { | ||
[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell]; | ||
} | ||
|
||
- (void)cellDidEndScrolling:(JGScrollableTableViewCell *)cell { | ||
if (cell.optionViewVisible) { | ||
_openedIndexPath = [self.tableView indexPathForCell:cell]; | ||
} | ||
else { | ||
_openedIndexPath = nil; | ||
} | ||
|
||
[JGScrollableTableViewCellManager closeAllCellsWithExceptionOf:cell]; | ||
} | ||
|
||
#pragma mark - Table view data source | ||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | ||
return 2; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
return 99; | ||
} | ||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
return 70.0f; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
static NSString *const CellIdentifier = @"ScrollCell"; | ||
JGScrollableTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; | ||
[cell setScrollViewBackgroundColor:[UIColor colorWithWhite:0.975f alpha:1.0f]]; | ||
[cell setScrollViewInsets:UIEdgeInsetsMake(0.0f, 1.0f, 1.0f, 1.0f)]; | ||
cell.contentView.backgroundColor = [UIColor colorWithWhite:0.7f alpha:1.0f]; | ||
|
||
JGScrollableTableViewCellAccessoryButton *optionView = [JGScrollableTableViewCellAccessoryButton button]; | ||
[optionView setButtonColor:[UIColor colorWithRed:0.975f green:0.0f blue:0.0f alpha:1.0f] forState:UIControlStateNormal]; | ||
[optionView setButtonColor:[UIColor colorWithRed:0.8f green:0.1f blue:0.1f alpha:1.0f] forState:UIControlStateHighlighted]; | ||
|
||
[optionView setTitle:@"Action" forState:UIControlStateNormal]; | ||
|
||
optionView.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 | ||
|
||
[cell setOptionView:optionView side:JGScrollableTableViewCellSideRight]; | ||
|
||
cell.scrollDelegate = self; | ||
|
||
[cell setOptionViewVisible:[_openedIndexPath isEqual:indexPath]]; | ||
|
||
return cell; | ||
} | ||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | ||
NSLog(@"Selected Index Path %@", indexPath); | ||
} | ||
|
||
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { | ||
NSLog(@"Deselected Index Path %@", indexPath); | ||
} | ||
|
||
@end |
22 changes: 0 additions & 22 deletions
22
JGScrollableTableViewCell ExamplesTests/JGScrollableTableViewCell ExamplesTests-Info.plist
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
JGScrollableTableViewCell ExamplesTests/JGScrollableTableViewCell_ExamplesTests.m
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
JGScrollableTableViewCell ExamplesTests/en.lproj/InfoPlist.strings
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// JGScrollableTableViewCell.h | ||
// ProTube 2 | ||
// | ||
// Created by Jonas Gessner on 03.11.13. | ||
// Copyright (c) 2013 Jonas Gessner. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class JGScrollableTableViewCell; | ||
|
||
@protocol JGScrollableTableViewCellDelegate <NSObject> | ||
|
||
@optional | ||
- (void)cellDidBeginScrolling:(JGScrollableTableViewCell *)cell; | ||
- (void)cellDidScroll:(JGScrollableTableViewCell *)cell; | ||
- (void)cellDidEndScrolling:(JGScrollableTableViewCell *)cell; | ||
|
||
@end | ||
|
||
typedef NS_ENUM(BOOL, JGScrollableTableViewCellSide) { | ||
JGScrollableTableViewCellSideLeft = NO, | ||
JGScrollableTableViewCellSideRight = YES | ||
}; | ||
|
||
@interface JGScrollableTableViewCell : UITableViewCell | ||
|
||
//scroll view peoperties | ||
/** | ||
Insets the scroll view. Useful for displaying a border around the scroll area (when also setting \c contentView.backgroundColor) | ||
*/ | ||
@property (nonatomic, assign) UIEdgeInsets scrollViewInsets; | ||
|
||
|
||
/** | ||
Sets the background color of the visible scroll area. | ||
*/ | ||
- (void)setScrollViewBackgroundColor:(UIColor *)scrollViewBackgroundColor; | ||
|
||
|
||
/** | ||
An instance conforming to the \c JGScrollableTableViewCellDelegate protocol. | ||
*/ | ||
@property (nonatomic, weak) id <JGScrollableTableViewCellDelegate> scrollDelegate; | ||
|
||
|
||
/** | ||
@warning When the cell is selected or highlighted the scroll view won't be able to scroll. (This shouldn't be a problem anyway) | ||
@return If the user is currently dragging the scroll view. | ||
*/ | ||
@property (nonatomic, assign, readonly) BOOL scrolling; | ||
|
||
|
||
//opened sides | ||
/** | ||
The current state of the option view. | ||
@return If the option view is visible. | ||
*/ | ||
@property (nonatomic, assign) BOOL optionViewVisible; | ||
|
||
|
||
/** | ||
Sets the current state of the option view with an optional animation of 0.3 seconds. | ||
*/ | ||
- (void)setOptionViewVisible:(BOOL)optionViewVisible animated:(BOOL)animated; | ||
|
||
|
||
//views | ||
/** | ||
@return The option view. | ||
*/ | ||
@property (nonatomic, strong, readonly) UIView *optionView; | ||
|
||
|
||
/** | ||
Sets & removes the old option view. | ||
@param view The option view to add. The view's width should be set, all ofther frame paramaters are ignored. | ||
@param side The side on which the view should be placed. Either left or right. | ||
*/ | ||
- (void)setOptionView:(UIView *)view side:(JGScrollableTableViewCellSide)side; | ||
|
||
|
||
/** | ||
Add a view to the scrolling area of the cell. | ||
@param view The view to add. | ||
*/ | ||
- (void)addContentView:(UIView *)view; | ||
|
||
@end | ||
|
||
|
||
@interface JGScrollableTableViewCellManager : NSObject | ||
|
||
/** | ||
Closes all optin views in \c Cell's UITableView. | ||
@param cell The cell that should not be closed. | ||
*/ | ||
+ (void)closeAllCellsWithExceptionOf:(JGScrollableTableViewCell *)cell; | ||
|
||
@end |
Oops, something went wrong.