views:

37

answers:

2

I've created a sub class of UITableViewController named LoginViewController with the XIB file using XCode. Then I opened the XIB file with IB and set the table's style to grouped. Finally I wrote the following code:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];
    [window addSubview: loginViewController.view];
    window.backgroundColor = [UIColor blueColor];
    [window makeKeyAndVisible];
    [window layoutSubviews];
}

I set the window's background color to blue for you to see what the problem is. I put a link to the screenshot

As you can see in the screenshot the table view is not display correctly because a margin between the bottom of the main window and the table view is being set and I don't know why.

If I don't use the table style grouped the problem does not occur

A: 

The UITableView inside your .xib file probably has a negative vertical offset (i.e. y-axis), which would mean you need to adjust the origin (likely to 0,0) and the frame (to, say, 320x400, or whatever your parent view height is).

Shaggy Frog
It seems that the origin is not in (0,0) because a tried to change it to (0,0) and nothing happend but this line solved it loginController.view.frame = [UIScreen mainScreen].applicationFrame;
GuidoMB
You're probably not solving your real problem doing that, just masking it.
Shaggy Frog
@Shaggy Frog Why do you say that I not solving the problem? For me it seems like the a sub view needs to be located in the same frame as it's parent view if I want it to be aligned with it
GuidoMB
I'm saying that if you tried to change the origin to 0,0 and you couldn't, then there's a problem there (you should be able to set the origin to 0,0), and so you're masking that problem by doing another action that seems to fix the problem, without understanding what the actual problem is.
Shaggy Frog
A: 

Hi, GuidoMB

this is the common problem while working with the IBOutlet...

Try to create a UITableView programatically by writing code for it.

dont do drang and drop...

specify the framesize of UITableView manually in coding...

specify datasource and delegate manually in coding...

you will deffinatly solved your problem...

even if any problem leave a comment...and accept answer by clicking correct sign if you get resolved....

enjoy the day...

yakub_moriss
It does not seem like a nice solution, I should be able to do such a simple task with Interface Builder
GuidoMB