Comments (15)
To reproduce, remove the unnecessary UI labels/imageviews from your row.
Remove the codes accordingly referencing those UI controls.
Use this code instead:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath isExpanded:(BOOL)isExpanded
{
static NSString *CellIdentifier = @"Content1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!isExpanded) //prepare the cell as if it was collapsed! (without any animation!)
{
cell.textLabel.text = @"!expanded";
}
else ///prepare the cell as if it was expanded! (without any animation!)
{
cell.textLabel.text = @"expanded";
}
return cell;
}
from hvtableview.
In this method:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath isExpanded:(BOOL)isExpanded
isExpanded is supposed to be false because at app start up all the cells are initially collapsed. You should use these two delegates for setting up your cells in expand/collapse states:
-(void)tableView:(UITableView *)tableView expandCell:(UITableViewCell *)cell withIndexPath:(NSIndexPath *)indexPath
-(void)tableView:(UITableView *)tableView collapseCell:(UITableViewCell *)cell withIndexPath:(NSIndexPath *)indexPath
checkout the project's readme.
from hvtableview.
Hi, can you be more specific, because I took your project and it isn't working correctly. Could you please double confirm on your side using the instructions I have provided to reproduce the problem? I believe we are talking about 2 different things here. I am referring to the boolean inside cellForIndexPath being always false, i.e. the parameter is useless. I do not wish to touch expandCell/collapseCell because cellForIndexPath is sufficient for me needs (if the boolean parameter gets updated correctly)
from hvtableview.
You have misunderstood the usage of cellForRowAtIndexPath. This method is only called when the tableview tends to load a new cell or when you scroll. You get isExpanded = TRUE when you e.g. scroll down to an expanded cell. YOU MUST USE expandCell & collapseCell methods for setting your cell's state change animation. And also prepare your cell in cellForRowAtIndexPath according to isExpanded state.
cellForRowAtIndexPath is not called when you expand a cell. So don't expect it's isExapnded parameter to be set!!!
Please read the Apple documents carefully. This is about the basics of UITableView. And I assure you the project is already double checked from my side.
from hvtableview.
Hi, I understand that the cellForRowAtIndexPath is not called when you expand a cell.
You are misunderstanding what I am trying to say. Please do me a huge favor - add this to your cellForRowAtIndexPath function and let me know if it appears or not. Of course, do scroll the table to make sure it gets refreshed while in expanded state.
if(isExpanded)
NSLog(@"this line will not appear");
from hvtableview.
- In the example project add these lines immediately after
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(isExpanded)
NSLog(@"this line will not appear");
- Run the project.
- Scroll to bottom.
- Expand the bottommost cell.
- Scroll to top.
- Scroll to bottom again.
from hvtableview.
The log showed up for you? That is weird because it didn't for me. It didn't even enter the breakpoint.
from hvtableview.
zip your project and send it to my email: [email protected]
from hvtableview.
I wrote about this issue several days ago but you closed this topic.
This issue takes place in your example project, where method cellForRowAtIndexPath ALWAYS returns FALSE (NO), even if I will expand the cell.
You can make two breakpoints in cellForRow and you will see the issue.
from hvtableview.
Uploaded to your email, please check.
from hvtableview.
Were you able to download it?
from hvtableview.
Yes, I will let you know.
from hvtableview.
A pull request from gavyaggarwal was causing this problem when expandOnlyOnceCell was FALSE; you were right. I have pushed a new commit with the bug fixed. Thanks for your report.
from hvtableview.
Fix confirmed. Adding expandedIndexPaths = [NSMutableArray new]; to init fixes the problems. I skipped out on integrating this to my project because of the time taken. I hope this is a good lesson for not ignoring user reports and actually test them out. This will not go well with customers in the real world, though you actually get paid for it there and not here. Good job, I appreciate the followup. Will use it in the future :)
from hvtableview.
As I said the problem was due to a pull request from gary something. I didnt have enough time to scrutinize every pull request; and I was confident because my commits were working without this bug. However thanks for your report and I will try to spend more time on merging people's pull requests.
Sent from my iPhone
On Sep 15, 2014, at 7:42 AM, CyberMew [email protected] wrote:
Fix confirmed. Adding expandedIndexPaths = [NSMutableArray new]; to init fixes the problems. I skipped out on integrating this to my project because of the time taken. I hope this is a good lesson for not ignoring user reports and actually test them out. This will not go well with customers in the real world, though you actually get paid for it there and not here. Good job, I appreciate the followup. Will use it in the future :)
—
Reply to this email directly or view it on GitHub.
from hvtableview.
Related Issues (20)
- Have you tried to implement it with swift? HOT 1
- Delegate methods not called HOT 1
- Fail to call "viewForHeaderInSection, heightForHeaderInSection" with multiple section's HOT 2
- -tableView:didSelectRowAtIndexPath and -tableView: cellForRowAtIndexPath: not called HOT 1
- Expand Cell is not Being called. HOT 8
- expand on accessory tap HOT 1
- How to expand a cell programatically? HOT 3
- Expand/collapse flicks my tableview HOT 9
- is there anyway to expand only cell at a time? if a cell is already expanded, and user tries to expand another cell, the first cell should be collapsed and the new cell should be expanded HOT 6
- Do you think update for swift? HOT 2
- It cannot create by code now? HOT 1
- Class missing HOT 3
- useful method canExpandAtIndexPath
- able to show context menu by using this library HOT 3
- wrong cell expanding/collapsing with multiple sections HOT 1
- Crash on -[UITableView _configureCellForDisplay:forIndexPath:]
- Wanted to show either a view or a button at a same location
- In iOS 11 table delegate methods are not called
- [self.tableview setEditing:YES] didn't work
- Multiple cell expansions does not work HOT 2
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 hvtableview.