简体   繁体   中英

UITableView adds empty rows above and below, still there after setting header and footer to empty views

In my view with a navigation bar, I THINK but not sure, that the empty spaces above and below my table are the header and footer. I've tried all possible options to set them to nothing but they still show up like this:

图片1

The same gap is at the top below the "Private Messages" nav bar. When I start to scroll:

图片2

it takes up the entire view. Why doesn't it initially take up the entire area? In the Size Inspector Header and Footer are set to 1. I'm pretty sure it has something to do with the header and footer. Any suggestions please?

It is dark Cocoa magic :)

Add

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.automaticallyAdjustsScrollViewInsets = NO;
        ... your additional code
    }
    return self;
}

to your view controller.

UPDATE: (from iOS7CourseSlides.pdf )

self.automaticallyAdjustsScrollViewInsets = YES;

is the same as

self.automaticallyAdjustsScrollViewInsets = NO;
self.contentSubview.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
self.contentSubview.contentOffset = CGPointMake(0, -64);

So you can use the approach you like more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM