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
64 changes: 30 additions & 34 deletions Classes/TSUIKit/TSTableView/Private/TSTableViewContentHolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ - (TSTableViewRow *)dequeueReusableRowView

- (void)addReusableRow:(TSTableViewRow *)row
{
[_reusableRows addObject:row];
if (row)
[_reusableRows addObject:row];
}

- (TSTableViewCell *)dequeueReusableCellViewWithIdentifier:(NSString *)identifier
Expand Down Expand Up @@ -345,7 +346,7 @@ - (void)loadSubrowsForRowAtPath:(NSIndexPath *)rowPath rowView:(TSTableViewRowPr
}
}

- (void)loadRow:(TSTableViewRowProxy *)row atPath:(NSIndexPath *)rowPath parentView:(UIView *)parentView
- (UIScrollView*)loadRow:(TSTableViewRowProxy *)row atPath:(NSIndexPath *)rowPath parentView:(UIScrollView *)parentView
{
VerboseLog();
NSInteger numberOfColumns = [self.dataSource numberOfColumns];
Expand All @@ -367,37 +368,42 @@ - (void)loadRow:(TSTableViewRowProxy *)row atPath:(NSIndexPath *)rowPath parentV
//if addSubview: is used during scrolling rows overlapping horizontal/vertical scoll indicators of UIScrollView
[parentView insertSubview:rowView atIndex:0];
row.rowView = rowView;
for(int j = 0; j < row.subrows.count; ++j)
{
TSTableViewRowProxy *subrow = row.subrows[j];
NSIndexPath *indexPath = [rowPath indexPathByAddingIndex:j];
[self loadRow:subrow atPath:indexPath parentView:row.rowView];
}
return rowView;
}

#pragma mark -

- (void)updateRowsVisibility
{
VerboseLog();
CGFloat tresholdOffset = self.bounds.size.height/3;
for(int i = 0; i < _rows.count; ++i) {
TSTableViewRowProxy *row = _rows[i];
[self updateRowsVisibilityHelper:row atPath:[NSIndexPath indexPathWithIndex:i] parentView:self];
}
}

- (void) updateRowsVisibilityHelper:(TSTableViewRowProxy*) row atPath:(NSIndexPath*) rowPath parentView:(UIScrollView *)parentView {
CGFloat tresholdOffset = parentView.bounds.size.height/3;
CGFloat topTreshold = self.contentOffset.y - tresholdOffset;
CGFloat bottomTreshold = self.contentOffset.y + self.bounds.size.height + tresholdOffset;
for(int i = 0; i < _rows.count; ++i)
if((topTreshold <= CGRectGetMinY(row.frame) && CGRectGetMinY(row.frame) <= bottomTreshold) ||
(topTreshold <= CGRectGetMaxY(row.frame) && CGRectGetMaxY(row.frame) <= bottomTreshold) ||
(CGRectGetMinY(row.frame) < topTreshold && bottomTreshold < CGRectGetMaxY(row.frame)))
{
TSTableViewRowProxy *row = _rows[i];
if((topTreshold <= CGRectGetMinY(row.frame) && CGRectGetMinY(row.frame) <= bottomTreshold) ||
(topTreshold <= CGRectGetMaxY(row.frame) && CGRectGetMaxY(row.frame) <= bottomTreshold) ||
(CGRectGetMinY(row.frame) < topTreshold && bottomTreshold < CGRectGetMaxY(row.frame)))
{
if(!row.rowView)
[self rowWillAppear:row atPath:[NSIndexPath indexPathWithIndex:i]];
}
else
{
if(row.rowView)
[self rowWillDissapear:row];
if(!row.rowView) {
//[self rowWillAppear:row atPath:rowPath];
parentView = [self loadRow:row atPath:rowPath parentView:parentView];

for(int j = 0; j < row.subrows.count; ++j)
{
TSTableViewRowProxy *subrow = row.subrows[j];
NSIndexPath *indexPath = [rowPath indexPathByAddingIndex:j];
[self updateRowsVisibilityHelper:subrow atPath:indexPath parentView:parentView];
}
}
} else {
if(row.rowView)
[self rowWillDissapear:row];
}
}

Expand All @@ -406,19 +412,9 @@ - (void)updateRowsVisibilityWithAnimation:(BOOL)animated
VerboseLog();
if(animated) // first show new visible rows and after delay hide not visible (because they could be still on screen while animation is in progress)
{
CGFloat tresholdOffset = self.bounds.size.height/3;
CGFloat topTreshold = self.contentOffset.y - tresholdOffset;
CGFloat bottomTreshold = self.contentOffset.y + self.bounds.size.height + tresholdOffset;
for(int i = 0; i < _rows.count; ++i)
{
for(int i = 0; i < _rows.count; ++i) {
TSTableViewRowProxy *row = _rows[i];
if((topTreshold <= CGRectGetMinY(row.frame) && CGRectGetMinY(row.frame) <= bottomTreshold) ||
(topTreshold <= CGRectGetMaxY(row.frame) && CGRectGetMaxY(row.frame) <= bottomTreshold) ||
(CGRectGetMinY(row.frame) < topTreshold && bottomTreshold < CGRectGetMaxY(row.frame)))
{
if(!row.rowView)
[self rowWillAppear:row atPath:[NSIndexPath indexPathWithIndex:i]];
}
[self updateRowsVisibilityHelper:row atPath:[NSIndexPath indexPathWithIndex:i] parentView:self];
}

[TSUtils performViewAnimationBlock:nil withCompletion:^{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>ECAD9E6C-5FD0-4089-8FBD-EAACD5E00E8F</string>
<key>IDESourceControlProjectName</key>
<string>TSTableView</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>8FF01852-9E57-4C88-861A-D9304AD2BD6D</key>
<string>https://github.com/justjefflee/TSTableView.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>TSTableView/TSTableView.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>8FF01852-9E57-4C88-861A-D9304AD2BD6D</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/justjefflee/TSTableView.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>8FF01852-9E57-4C88-861A-D9304AD2BD6D</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>8FF01852-9E57-4C88-861A-D9304AD2BD6D</string>
<key>IDESourceControlWCCName</key>
<string>TSTableView</string>
</dict>
</array>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>F6141F6117C6A725003455EB</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
2 changes: 1 addition & 1 deletion TSTableView/TSTableView/TSTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ - (void)tableView:(TSTableView *)tableView willSelectRowAtPath:(NSIndexPath *)ro
VerboseLog();
}

- (void)tableView:(TSTableView *)tableView didSelectRowAtPath:(NSIndexPath *)rowPath
- (void)tableView:(TSTableView *)tableView didSelectRowAtPath:(NSIndexPath *)rowPath selectedCell:(NSInteger)cellIndex
{
VerboseLog();
}
Expand Down