One Quickie


Laying out tableview cell when entering / exiting edit mode (UITableView->General)
Entering and exiting UITableView edit mode has a cool animation. If you've got a custom subclass, your goodies don't move unless you override layoutSubviews in your UITableViewCell subclass. Any view position changes will automatically be animated.
- (void) layoutSubviews {

    // skootch stuff over
    if (self.editing && !self.showingDeleteConfirmation) {
#define MARGIN 40.0
        CGRect frame = CGRectMake (MARGIN + 4.0, 4.0, 70.0, 46.0);
        _profileView.frame = frame;

        frame = CGRectMake (MARGIN + 80.0, 0, 240.0 - MARGIN, 55.0);
        _titleLabel.frame = frame;

    // layout normally
    } else {
        CGRect frame = CGRectMake (4.0, 4.0, 70.0, 46.0);
        _profileView.frame = frame;

        frame = CGRectMake (80.0, 0, 240.0, 55.0);
        _titleLabel.frame = frame;
    }

    [super layoutSubviews];
} // layoutSubviews
The showingDeleteConfirmation test is so you don't move things around if the user does the "swipe-right to show delete button" thing.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com