Problem Adding Table Header


#1

When I set the table header view, my Edit and New buttons appear at top of screen, but the table entries are no longer there as if the table view is obscured by the header. My header size is 320x41 in the .xib file and the .xib is loading as the buttons show up. The background attribute has been set to clear and FileOwner set to BNRItemsViewController.

If i comment out the following in ViewDidLoad, the 5 random table items do appear again.
Any ideas?

-(void) viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
    // when i put header, the table vanishes and is not visible now
    //UIView *header = self.headerView;
    //[self.tableView setTableHeaderView:header];
    
}

#2

I have found cellForRowAtIndexPath is not being called if I execute the UIView *header = self.headerViewmethod that was added to load the .xib.


#3

Hey, I had the same problem, turned out to be a bad .xib.

“Open the xib in xcode, select File’s Owner and click on the “Connection Inspector” (upper right arrow), to see all outlets at once. Look for !s which indicates a missing outlet.”

source: stackoverflow.com/questions/1379 … -for-the-k


#4

Thanks. This was the case! However I remade the connections, cleaned the project, rebuilt and I have same situation.

If I comment out a single line (to create the table header) it works and shows my five entries.


#5

Double check your connections, make sure that the File’s Owner connection is to the ‘headerView’ and not just the ‘View’.


#6

Weird. My headerView would not show at all.
So I went to HeaderView.xib, clicked the File Owner placeholder, checked out the Connections and noticed that the headerView outlet wasn’t connected at all. So I dragged from the connections from headerView to the view in my .xib file and it worked.

Bit confused why this wasn’t set to begin with!


#7

I had the same problem and solution as @Arthurzwit.


#8

I also had to go into the Connections Inspector for the Edit button and drag the touchUpInside event into the toggleEditingMode method to get the method to be called. I suppose I’ll have to do this for the New button and addNewItem method as well.


#9

Make sure you are doing tableView:heightForHEADERInSection: and tableView:viewForHEADERInSection:


#10

Hi,
I am blind and use voiceover for navigation, thus I may be doing something wrong, since interacting with Xcode using voiceover is quite different, thus may be missing a step or not doing something this is obvious to a sighted person.
I have made my connection from the buttons to the File’s Owner, but the step I think I am missing is making the connection from the HeaderView to the main view controller. I don’t know how to do this using voiceover because there is no XIB file for the view controller since I am using the tableview as the main view controller.
Any help appreciated.


#11

[quote=“mythral0”]Hi,
I am blind and use voiceover for navigation, thus I may be doing something wrong, since interacting with Xcode using voiceover is quite different, thus may be missing a step or not doing something this is obvious to a sighted person.
I have made my connection from the buttons to the File’s Owner, but the step I think I am missing is making the connection from the HeaderView to the main view controller. I don’t know how to do this using voiceover because there is no XIB file for the view controller since I am using the tableview as the main view controller.
Any help appreciated.[/quote]

Did you make the connection from the File’s Owner to the UIView that holds the Edit and New buttons by Control-Dragging from the File’s Owner onto the UIView and selecting the headerView connection?


#12

Had the same problem. Turns out that the view I was using for the header had been connected to the file’s owner as the ‘view’. It only replaced the scrollview when the nib was instantiated - which only happened when the headerView was referenced. So referencing the headerview to put it in place also replaced the *vew ivar.

Sigh.