Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Dealing with multiple views is pretty easy if you understand the concept behind the views. For example your Delegate could be linked to an empty parent View. Then you just create your children views and add them to the parent view with <strong>addSubview</strong>. The last added view is the one that will be displayed in the foreground.</p> <p>Now you can bring the views into the front using <strong>bringSubviewToFront</strong> method. Keep in mind that all your views are kept in memory until you remove them from the parent view using the children view's <strong>removeFromSuperview</strong> method.</p> <p>Swapping views is just removing the child view before you add the next one but then you have to decide if you want to retain them or if you want to release them but then you need to *<em>re-create</em> (alloc / init) the views later.</p> <p>BTW If you views are not at the right place then you either need to adjust the positions relative to the parent view or set them right in the interface builder because iOS will not reposition them because you add them as sub view.</p> <p>For example I used that code to switch between a view that displays an Ad or a ticker:</p> <pre><code>- (void) showAds:(BOOL)flag { if( showAds != flag ) { while([[self.bottomView subviews] count] &gt; 0 ) { [[[self.bottomView subviews] objectAtIndex:0] removeFromSuperview]; } showAds = flag; if( showAds ) { [self.tickerViewController stop]; [self.bottomView addSubview:self.adViewController.view]; } else { [self.bottomView addSubview:self.tickerViewController.view]; [self.tickerViewController start]; } }} </code></pre> <p>The 2nd line makes sure I don't remove and add if nothing has changed. The next 3 lines remove any residual sub views. After that either add the Add or the Ticker view as my current sub view (including making sure the ticker is started / stopped properly).</p> <p>Hope that helps.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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