last day (14 days later) » 

01:52
0
A: Assertion Failure when updating uitableview

Mitchell CurrieI have had a similar problem, however I perform a reload like so: - (void)noteSectionHeader:(UTNoteSectionHeader *)noteSectionHeader sectionTapped:(NSInteger)section { //check our action if(<will hide section>) { //hide section <some action> } els...

I actually don't use rows as "headers". I use sections as my main headers. So my row count is 0 until one section is tapped. then it should be 1 (for now)
then please adjust it accordingly. the logic is the same. your section will have 0 rows if it is not visible, and the click event will be - (void)noteSectionHeader:(UTNoteSectionHeader *)noteSectionHeader sectionTapped:(NSInteger)section
I have adjust the answer to more closely match your scenario, let me know if this helps;
Works on the first click, when I click another section it fails again :(
are you modifying the data at all? did you remove all calls to add and delete rows?
I will edit my question. Maybe I forgot to tell you that I only wish one section open at a time
01:52
I do not see you reloading the old section that closes when you select a new section. do you handle this case?
What about your code that gets the number of rows and cell for row at index path?
Let me help you here.
arh chat :)
much easuer
I try to use your reloadSections method now in every case
I'm more worried about your data
show me the code for number of rows and cell at indexpath
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

if (self.selectedSection == section) {
return 1;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"TitleCell";

UTNoteTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

UTNoteItem* item = [self.notes objectAtIndex:indexPath.section];

cell.noteText.text = item.text;
return cell;
}
01:56
you should only call reload once per method, if you need multiple sections add them together in the indexpathset
ok that looks good, no data being added or deleted
:)
One moment
I used the deletePaths etc because they showed it in a wwdc movie
I see, you're not readlly deleting paths, just hiding them.
I suggest reloading the table between the first affected section and the last
And it works in my master branch, but when I edited my model to not know about the headerView it turned out to become a nightmare
you must be careful with delete and other table view actions
use them carefully
they are asynchronous which means they may take some time to be effective
so if you call too many things at once
the order may become unstable
see this call: [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
you may add multiple index sections
[NSIndexSet indexSetWithIndexesInRange:NSRangeMake(min(a,b),max(a,b) ) ];
where a and b are two sections
sorry there is a mistake there it should not be max(a,b) it must be the length
I hope this makes sense
NSMutableIndexSet* reloadSet = [[NSMutableIndexSet alloc] init];
/* Check if a section is opened */
if (self.selectedSection != NSNotFound) {
/* A section is open, get the item */
UTNoteItem* theItem = self.notes[self.selectedSection];
/* if the item is the section opened, close it */
if (self.selectedSection == section) {
theItem.selected = NO;
[reloadSet addIndex:section];
self.selectedSection = NSNotFound;

}
/* The item is not the section, so open it, and close the previous item */
else {
theItem.selected = YES;
that code works
02:03
yes that's great
does it work completely?
Yes, just looks horrible :p
With the glowing effects and everything :p
I see
you mean
the highlight when you select it?
Everything that is reloaded will fade out while a new instance is fading in, which result in a light effect.
you can disable the animations for that if you prefer
what is the desired effect?
you may also change the animation
typedef enum {
UITableViewRowAnimationFade,
UITableViewRowAnimationRight,
UITableViewRowAnimationLeft,
UITableViewRowAnimationTop,
UITableViewRowAnimationBottom,
UITableViewRowAnimationNone,
UITableViewRowAnimationMiddle,
UITableViewRowAnimationAutomatic = 100
} UITableViewRowAnimation;
Constants
UITableViewRowAnimationFade
The inserted or deleted row or rows fades into or out of the table view.
Available in iOS 2.0 and later.
Declared in UITableView.h.
UITableViewRowAnimationRight
The inserted row or rows slides in from the right; the deleted row or rows slides out to the right.
hmm, hard to tell :p
02:07
try left or right?
It should look like you are expanding the contents of the selected "note"
so no left or right
ah ok
UITableViewRowAnimationTop
ye
yes still gets that glowy effect though :(
this is odd.
hehe
02:10
you may need to manually synchronise the animations for deleting and adding
i.e.
perform the delete
and THEN
perform the add
yes, I guess. This will be another topic for tommorow maybe :)
For now the most important is done thanks to you
happy to help
+1 and the mark
Thanks :)
thanks, good luck and happy developing
02:25
Wuhu.. fix'd with this code:
- (void)noteSectionHeader:(UTNoteSectionHeader *)noteSectionHeader sectionTapped:(NSInteger)section
{
NSMutableArray* delete = [NSMutableArray new];
NSMutableArray* add = [NSMutableArray new];

NSInteger previousItemIndex = self.selectedSection;

/* Check if a section is opened */
if (self.selectedSection != NSNotFound) {
/* A section is open, get the item */
UTNoteItem* theItem = self.notes[self.selectedSection];
/* if the item is the section opened, close it */
if (self.selectedSection == section) {

last day (14 days later) »