alekseyn / EasyTableView

Horizontal and vertical scrolling table views for iOS
BSD 3-Clause "New" or "Revised" License
584 stars 157 forks source link

rotation multiple sections #14

Closed BrandonCopley closed 12 years ago

BrandonCopley commented 12 years ago

update the section code to this:

I had issues forking and trying to sync. Github kept timing out.

-(UIView)tableView:(UITableView )tableView viewForHeaderInSection:(NSInteger)section{ if ([delegate respondsToSelector:@selector(easyTableView:viewForHeaderInSection:)]) {

    UIView *view = [[UIView alloc] init];
    UIView *rotatedView = [delegate easyTableView:self viewForHeaderInSection:section];

    if (_orientation == EasyTableViewOrientationHorizontal) {
        rotatedView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        rotatedView.transform = CGAffineTransformMakeRotation(M_PI/2);
        view.frame = CGRectMake(0, 0, rotatedView.frame.size.height, rotatedView.frame.size.width);
        rotatedView.frame = CGRectMake(0, rotatedView.frame.size.width-rotatedView.frame.size.height, rotatedView.frame.size.width, rotatedView.frame.size.height);
    }
    else {
        rotatedView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        view.frame = CGRectMake(0, 0, rotatedView.frame.size.width, rotatedView.frame.size.height);
        rotatedView.frame = view.frame;
    }

    rotatedView.clipsToBounds = YES;

    view.clipsToBounds = YES;
    [view addSubview:rotatedView];

    return view;
}
return nil;

}

-(UIView)tableView:(UITableView )tableView viewForFooterInSection:(NSInteger)section{

if ([delegate respondsToSelector:@selector(easyTableView:viewForFooterInSection:)]) {
    UIView *view = [[UIView alloc] init];
    UIView *rotatedView = [delegate easyTableView:self viewForFooterInSection:section];

    if (_orientation == EasyTableViewOrientationHorizontal) {
        rotatedView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        rotatedView.transform = CGAffineTransformMakeRotation(M_PI/2);
        view.frame = CGRectMake(0, 0, rotatedView.frame.size.height, rotatedView.frame.size.width);
        rotatedView.frame = CGRectMake(0, rotatedView.frame.size.height-rotatedView.frame.size.width, rotatedView.frame.size.width, rotatedView.frame.size.height);
    }
    else {
        rotatedView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        view.frame = CGRectMake(0, 0, rotatedView.frame.size.width, rotatedView.frame.size.height);
        rotatedView.frame = view.frame;
    }

    rotatedView.clipsToBounds = YES;

    view.clipsToBounds = YES;
    [view addSubview:rotatedView];

    return view;
}
return nil;

}

alekseyn commented 12 years ago

I tried your suggestions but ran into an issue with orientation changes. However, with a few modifications I was able to get it working in all test cases, including device orientation changes. To ensure proper layout and sizing, header and section views for horizontal table views MUST have the same height as the horizontal table view itself. I enforce this within EasyTableView as well. Please pull the latest changes and let me know how it works out for you. Thanks for your help.

BrandonCopley commented 12 years ago

Testing now - I just have issues because all my projects use ARC