Note that there are some explanatory texts on larger screens.

plurals
  1. POiphone UIView subclass not initializing as requested
    primarykey
    data
    text
    <p>I am new to objective-c and iPhone development but so far everything was going well til I tried to dig deeper (well not too deep). My problem is that I cannot initialize a specific UIView subclass with a specific coordinates for different orientations. </p> <p>The rotation is working great but the problem is when the app initializes. I was thinking of giving a different layout for different orientation.</p> <p>My app is actually an iPad app with a main UIViewController and three subviews (UIView s). lets call the view1, view2 and view3.</p> <p>The three views are created on the project's nib and outlets are coded and connected for them. </p> <p>The problem seems to be generating from the viewDidLoad method... it currently looks like this:</p> <pre><code>-(void)viewDidLoad{ [super viewDidLoad]; [view1 removeFromSuperview]; [view2 removeFromSuperview]; [view3 removeFromSuperview]; UIInterfaceOrientation curOrientation = self.Orientation; if(curOrientation == UIInterfaceOrientationPortrait) { view1 = [[XView alloc] initWithFrame:CGRectMake(20,492,728,492)]; view2 = [[YView alloc] initWithFrame:CGRectMake(384,20,364,472)]; view3 = [[ZView alloc] initWithFrame:CGRectMake(20,20,364,472)]; [self.view addSubview:view1]; [self.view addSubview:view2]; [self.view addSubview:view3]; } else if(curOrientation == UIInterfaceOrientationLandscapeRight) { //Different coordinates } else if(curOrientation == UIInterfaceOrientationLandscapeLeft) { //Different Coodinates } } </code></pre> <p>My problem is that the views are not getting the same coordinates as the ones given in the viewDidLoad method and they seem to be initialized at x=0, y=0. However, when I rotate the device everything works like a charm and every UIView is set in its right place for each orientation. Basically I just call the setFrame method for each UIView.</p> <p>I am not sure what am doing wrong here.... I need help...</p> <p>Regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload