Comments (9)
In the Outline sample project, "Heading 1.1" is a "synchronously and lazily loaded child". When I click "Heading 1.1" for the first time, I see NO passed in for collapsed as expected. More importantly, the UI behaves as you would expect.
Could you elaborate a bit or give me more detailed reproduction steps?
from tlindexpathtools.
I think I see what's going on. It seems your node is initialized to expanded (with zero children). So the first time you tap it, it gets collapsed. You just need to initialize the node to be collapsed. You would do that through the collapsedNodeIdentifiers
argument of the data model initializer:
self.dataModel = [[TLTreeDataModel alloc] initWithTreeItems:self.treeItems collapsedNodeIdentifiers:<initial collapsed node identifiers>];
Collapsing a node collapses all child nodes. So you just need to include the identifier of your node or one of it's ancestors.
from tlindexpathtools.
This is probably the issue. I call initWithTreeItems:collapseNodeIdentifiers:
when setting up the level 0 nodes in viewDidLoad
, but not sure where to call this when lazy loading the child nodes in willChangeNode
.
I've pasted the relevant code I'm using to help identify the issue here: http://pastebin.com/47sFYfeN
from tlindexpathtools.
OK, I got it now. Lazy loaded nodes default to expanded. I need to provide a way to specify their initial expanded/collapsed state. I'll look into it.
from tlindexpathtools.
Fixed. Now you can specify the initial collapsed state of lazy loaded child nodes. This involved some API changes, so you'll need to make some minor updates to your code. Here is a run-down of the changes:
- Collapsed node identifiers are now specified as an
NSArray
instead of anNSSet
. This change was made to simplify coding sinceNSArray
can be specified as a literal like@[item1, item 2, ...]
whileNSSet
can't. - The
[TLTreeTableViewController setNewVersionOfItem:]
method now takes an additional argumentcollapsedChildNodeIdentifiers
, which provides the opportunity to initialize the collapsed state of lazy loaded child nodes. - The
willChangeNode
delegate method no longer has a return value. So for the synchronous case, instead of returning the new tree item, you callsetNewVersionOfItem
from withinwillChangeNode
. This makes the synchronous and asynchronous cases more consistent. - The convenience method
[TLIndexPathItem identifiersForIndexPathItems:]
was added to simplify creating arrays of item identifiers. So now, the child identifiers for a given tree item can be created using[TLIndexPathItem identifiersForIndexPathItems:treeItem.childItems]
.
The example project was updated to incorporate all of the above changes.
from tlindexpathtools.
Implemented the changes and the issues is resolved. I have more questions about combining some of your library features, like getting dynamic heights with this, search working, and styling cells. Do you prefer that I open questions on StackOverflow so that it is visible to the community and your library gets exposure?
from tlindexpathtools.
Also noticed an issue with the cell remaining selected when clicked (highlighted in blue as the default behavior).
from tlindexpathtools.
Great. Yes, I do think the visibility on StackOverflow would help the library gain some traction.
from tlindexpathtools.
I forgot to mention the highlight. I changed the behavior because, in the spirit of keeping things light-weight and focused, I don't think the library should be responsible for it. The behavior could vary by app. So what you should do is override didSelectRowAtIndexPath
like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
And if you don't want leaf nodes to be selectable at all, you can do this:
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TLIndexPathTreeItem *item = [self.indexPathController.dataModel itemAtIndexPath:indexPath];
return item.childItems == nil ? nil : indexPath;
}
Perhaps it would make sense to include these in the sample project with some comments?
from tlindexpathtools.
Related Issues (20)
- TLCollectionViewController with fetchRequest delete NSManagedObject fault crash HOT 2
- Changing the TLIndexPathDataModel while animations under way causes crash HOT 1
- DataModel+IndexPathUpdates do not detect modified Core Data model objects HOT 2
- Realm HOT 3
- Same item in multiple sections: Possible? HOT 2
- Swift support HOT 4
- Warning : Duplicate Item Ignored (Noob Question) HOT 2
- Wrong optionality on controller: willUpdateDataModel: HOT 2
- Swift support HOT 1
- Swift Implementation Question HOT 2
- TLCollapsibleTableViewController
- Crash when reordering items HOT 2
- Unable to get dynamic height working HOT 4
- Cocoa Pod HOT 2
- TLTreeTableViewController: Keep only one expanded parent (close others) HOT 2
- NSManagedObject changes not detected by TLIndexPathController HOT 19
- Analysis Warning -- FYI HOT 1
- Another Suggestion Needed : Boxing Swift Structs HOT 4
- Non-ideal hash calculation HOT 3
- Drawback in case of adding dynamic data from API in multilevel expandable tableview/accordion HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tlindexpathtools.