Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging view repositions them at (0,0)
    primarykey
    data
    text
    <p>I created a simple window with the purpose of being something like a "Wizard" (I know Apple guidelines basically forbid you to, I tried to convince the customer, but whatever.</p> <p>It is just a simple view with two Custom Views inside, one in the bottom part which contains a "previous" and "next" button, and a bigger view at the top which takes most of the space.</p> <p>I called the bottom view "NavigationView" and the top one "ContainerView".</p> <p>I created an array to hold a series of views the user is supposed to navigate through with the "next" and "previous" buttons.</p> <p>So, here's my code.</p> <pre><code>- (IBAction) next:(id)sender{ currentViewIndex++; [self animatePushView:YES]; } - (IBAction)previous:(id)sender{ currentViewIndex--; [self animatePushView:NO]; } - (void) animatePushView:(BOOL)forward{ NSView *nextView = [viewCollection objectAtIndex:currentViewIndex]; for (NSView *subView in [containerView subviews]) { [subView removeFromSuperview]; } [containerView addSubview:nextView]; [nextView setFrame:containerView.bounds]; [containerView setNeedsDisplay:YES]; } </code></pre> <p>It's pretty straightforward I think. I have an array which contains the next view to be displayed.</p> <p>What happens is that I find the next view centered in the lower left part of the ContainerView. Why does this happen?</p> <p>Also, as you may have guessed, I'm a newbie at managing views, even though I've been working on objective-c for quite some time, so if there's some best practice I'm missing I'm open to suggestions. Thanks!</p> <p>EDIT:</p> <p>I forgot to add: Some of these views have different sizes, and I would like to be able to change the window size according to the view size.</p>
    singulars
    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.
 

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