Skip to content

Commit 11a3dbc

Browse files
committed
README update [skip ci]
1 parent 598213a commit 11a3dbc

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

README.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,27 @@ Check out the example project for sample table and collection views that use the
5959
_wizardDataSource = [[SSArrayDataSource alloc] initWithItems:
6060
@[ @"Merlyn", @"Gandalf", @"Melisandre" ]];
6161

62-
// SSDataSources creates your cell and calls
63-
// this configure block for each cell with
64-
// the object being presented in that cell,
65-
// the parent table or collection view,
66-
// and the index path at which the cell appears.
62+
// SSDataSources creates your cell and calls
63+
// this configure block for each cell with
64+
// the object being presented in that cell,
65+
// the parent table or collection view,
66+
// and the index path at which the cell appears.
6767
self.wizardDataSource.cellConfigureBlock = ^(SSBaseTableCell *cell,
6868
NSString *wizard,
6969
UITableView *tableView,
7070
NSIndexPath *indexPath) {
7171
cell.textLabel.text = wizard;
7272
};
7373

74+
self.wizardDataSource.tableActionBlock = ^BOOL(SSCellActionType action,
75+
UITableView *tableView,
76+
NSIndexPath *indexPath) {
77+
// Disallow gestures for moving and editing.
78+
// You could instead do something like allowing only editing:
79+
// return action == SSCellActionTypeEdit;
80+
return NO;
81+
};
82+
7483
// Set the tableView property and the data source will perform
7584
// insert/reload/delete calls on the table as its data changes.
7685
// This also assigns the table's `dataSource` property.
@@ -95,7 +104,7 @@ self.wizardDataSource.emptyView = noItemsLabel;
95104
96105
// Optional - row animation for table updates.
97106
self.wizardDataSource.rowAnimation = UITableViewRowAnimationFade;
98-
107+
99108
// Automatically inserts two new cells at the end of the table.
100109
[self.wizardDataSource appendItems:@[ @"Saruman", @"Alatar" ]];
101110
@@ -104,7 +113,7 @@ self.wizardDataSource.rowAnimation = UITableViewRowAnimationFade;
104113
105114
// Sorry Merlyn :(
106115
[self.wizardDataSource moveItemAtIndex:0 toIndex:1];
107-
116+
108117
// Remove the second and third cells.
109118
[self.wizardDataSource removeItemsInRange:NSMakeRange( 1, 2 )];
110119
```
@@ -115,10 +124,10 @@ Perhaps you have custom table cell classes or multiple classes in the same table
115124
self.wizardDataSource.cellCreationBlock = ^id(NSString *wizard,
116125
UITableView *tableView,
117126
NSIndexPath *indexPath) {
118-
if ([wizard isEqualToString:@"Gandalf"]) {
119-
return [MiddleEarthWizardCell cellForTableView:tableView];
120-
} else if ([wizard isEqualToString:@"Merlyn"]) {
121-
return [ArthurianWizardCell cellForTableView:tableView];
127+
if ([wizard isEqualToString:@"Gandalf"]) {
128+
return [MiddleEarthWizardCell cellForTableView:tableView];
129+
} else if ([wizard isEqualToString:@"Merlyn"]) {
130+
return [ArthurianWizardCell cellForTableView:tableView];
122131
}
123132
};
124133

@@ -128,9 +137,20 @@ Your view controller should continue to implement `UITableViewDelegate`. `SSData
128137

129138
```objc
130139
- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
131-
NSString *wizard = [self.wizardDataSource itemAtIndexPath:indexPath];
132-
133-
// do something with `wizard`
140+
NSString *wizard = [self.wizardDataSource itemAtIndexPath:indexPath];
141+
142+
// do something with `wizard`
143+
}
144+
145+
- (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath {
146+
NSString *wizard = [self.wizardDataSource itemAtIndexPath:indexPath];
147+
148+
// Calculate and return a height for `wizard`.
149+
// You might do something like...
150+
return [wizard boundingRectWithSize:CGSizeMake(CGRectGetWidth(tv), CGFLOAT_MAX)
151+
options:NSStringDrawingUsesLineFragmentOrigin
152+
attributes:@{ NSFontAttributeName : [UIFont boldSystemFontOfSize:14] }
153+
context:NULL].height;
134154
}
135155
```
136156

@@ -259,9 +279,9 @@ You're a modern wo/man-about-Internet and sometimes you want to present a `UITab
259279
@implementation SSCoreDataTableViewController
260280
261281
- (void) viewDidLoad {
262-
[super viewDidLoad];
263-
264-
NSFetchRequest *triggerFetch = [Trigger MR_requestAllSortedBy:[Trigger defaultSortField]
282+
[super viewDidLoad];
283+
284+
NSFetchRequest *triggerFetch = [Trigger MR_requestAllSortedBy:[Trigger defaultSortField]
265285
ascending:[Trigger defaultSortAscending]];
266286
267287
_dataSource = [[SSCoreDataSource alloc] initWithFetchRequest:triggerFetch

0 commit comments

Comments
 (0)