UITableView scroll and reload führt zu crash

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • UITableView scroll and reload führt zu crash

    Hallo zusammen,

    ich habe eine UITableView in der bei einer Action eine Zelle hinzugefügt wird. Nichts besonderes. Nach dem hinzufügen wird diese Zelle auch direkt mit einer Animation neu geladen:

    Quellcode

    1. [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationBottom];


    Jetzt will ich aber das die UITableView davor nochmal zur Zelle 0 scrollt. Dies geht mit folgendem Code:

    Quellcode

    1. [tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];


    Nehme ich beide Sachen, crasht die App. Nehme ich nur eine der beiden Sachen, funktioniert die Sache. Crash Log:

    Quellcode

    1. *** Assertion failure in -[UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:], /SourceCache/UIKit/UIKit-2348/UITableViewSupport.m:2596
    2. *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cell animation stop fraction must be greater than start fraction'
    3. *** First throw call stack:
    4. (0x38bbe6c3 0x316fa97f 0x38bbe57d 0x393532ef 0x35867331 0x358668b3 0x358603c3 0x3585f35f 0x3585c221 0x358b9ae5 0x2251b 0x3938baaf 0x38b939ff 0x38b936b1 0x38b92321 0x38b0539d 0x38b05229 0x347bd31b 0x3587b8f9 0x1d99d 0x1c1a0)
    5. libc++abi.dylib: terminate called throwing an exception


    Ich habe auch schon in Google danach gesucht aber nichts gefunden. Vielleicht kann mir hier ja jemand helfen.

    LG,

    Florian
  • Danke! Genaus das war's ;) Der Code für den Footer sieht jetzt so aus:

    Quellcode

    1. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    2. UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
    3. view.backgroundColor = [UIColor clearColor];
    4. return view;
    5. }


    Vorher hatte ich nur [[UIView alloc] init] und habe keinen Frame mit CGRectZero gesetzt. Jetzt funktioniert's.