Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SplitView detail view returns wrong view frame ?

I am using a splitView in iPad app. the detail view has 2 subView in it that draws themselves according to the etail view bounds. the problem is that they always draw themselves in (1024, 768) even when the ipad is in landscape mode.

BTW - if i call then in portrait mode and then rotate the ipad they do scale to (706,768).

I have checked the detail view frame and bounds as it created (in the view did load method) and in both cases i get this:

NSLog(@"screen frame = %@",NSStringFromCGRect(self.view.frame));
NSLog(@"screen bounds = %@",NSStringFromCGRect(self.view.bounds));

In the debug window I get:

2011-03-03 10:58:19.376 English Club[63347:207] screen frame = {{0, 0}, {768, 1024}}
2011-03-03 10:58:19.382 English Club[63347:207] screen bounds = {{0, 0}, {768, 1024}}

I cannot find out where the problem is. Can anyone help me?

Thanks for any help.

like image 770
shannoga Avatar asked Mar 03 '11 09:03

shannoga


3 Answers

In viewDidLoad the view is not supposed to have its real size. That is set up later by layout methods. But that shouldn't stop you :) How do you set your autoresizing mask? If you have set it correctly, everything should be ok.

like image 105
Sulthan Avatar answered Nov 09 '22 06:11

Sulthan


if you wait for -(void)viewDidLayoutSubviews it will have the right size

like image 41
Little Watchman Avatar answered Nov 09 '22 07:11

Little Watchman


I am currently writing a UISplitViewController app, and was disappointed to find out changing the the size of the detail or master view is forbidden. It is totally in charge of the size of the those sub frames.

Like UINavigationController and UITabBarController, UISplitViewController is a 'container' view controller, and it shapes it's subviews to fit it's purposes.

The function self debugDumpTheFrames prints out the uisplitviewcontroller's frame and it's two subframes. I print the frames in the splitViewController's viewDidLoad, and set a timer to call this function a second time 2 seconds later (during which time i Do nothing):

[self debugDumpTheFrames];
NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(debugDumpTheFrames) userInfo:nil repeats:NO];

If we look at the output, we can see that sometime after viewdidload, the UISplitViewController has changed the frames of it's subviews.

size of splitviewcontrollers view frame {{0, 0}, {748, 1024}}
size of splitviewcontrollers detail view frame {{0, 0}, {768, 1024}}
size of splitviewcontrollers master view frame {{0, 0}, {768, 1024}}

size of splitviewcontrollers view frame {{0, 0}, {748, 1024}}
size of splitviewcontrollers detail view frame {{321, 0}, {703, 748}}
size of splitviewcontrollers master view frame {{0, 0}, {320, 748}}

Where exactly it does this resizing I am unsure; but the uisplitviewcontroller is the boss of those frames, and they are private properties so touching them is grounds for rejection from the store.

like image 3
Tom Schulz Avatar answered Nov 09 '22 06:11

Tom Schulz