Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7647209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:24:28+00:00 2026-05-31T10:24:28+00:00

I use the scrollview to display multipage view, which have more than 10 pages.

  • 0

I use the scrollview to display multipage view, which have more than 10 pages. (scrollview.PageEnabled=true)

And every single page in scrollview has about 6 sub-view(named:ABCUI) which every one is loaded from nib :

    this.scrollview.DecelerationEnded+= scrollView_DecelerationEnded(...);

    public void LoadSubView(int nPageNo)
    {
       if (this.PageLoaded(nPageNo))
          return;

       for (int i=0;i<6;i++)    
       {
         ABCViewController abcUI=MonoTouch.Foundation.NSBundle.MainBundle.LoadNib ("ABCUI", this, null); //XIB file size: 20K

         abcui.SetTitle(...);  
         abcui.SetXXXX(...);
         abcui.frame = ..  pageFrame.X += this.ScrollView.Frame.Width+nPage*...;    

         this.scrollview.addsubview(abcUI.view,...);
       }
    }


    public void scrollView_DecelerationEnded (object sender, EventArgs e)
    {
        int nPageNo=(int)Math.Ceiling((this.ScrollView.ContentOffset.X+1)/this.ScrollView.Frame.Width);

        this.LoadSubView(nPageNo +1);
        this.LoadSubView(nPageNo - 1);  
    }

public void Button1Clicked(object sender, EventArgs e)
{
   this.ClearViewsInScrollView();
   this.LoadSubView(1); 
}

When the user trigger the button1 click, it will load the first page into scrollview(only 1 page oncetime, but 1 page has 6 sub-view), and when user scroll the scrollview , it will load the next page.

But it will take a long time when load the first page or switch page in scrollview , so the user must waiting:

  1. ipad1: about 1000ms
  2. iPad2: about 600ms
  3. in simulator: 100ms;

how to optimize the performance(reduce to less 300ms/ipad1)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:24:29+00:00Added an answer on May 31, 2026 at 10:24 am

    Very good question and excellent timing, since I have been working on something like this the past few days.

    Now, I am not sure if this solution will get you < 300ms loading, however in theory it is faster.

    (You’ll see both “XIB” and “NIB” terms. I am referring to the same thing. After all, a NIB is a “compiled” XIB.)

    The key to the whole thing is to prevent loading of each XIB file multiple times. There is no reason for it, since what you (we) basically need from it, are instances from the objects in the XIBs, and not the XIBs themselves occupying memory.

    Fortunately, the iOS SDK provides the UINib class which can do what we want. With this class, we can create multiple instances of the contents of a XIB, without having to load the XIB itself each time, just once in the “beginning”.

    Here’s how to do it:

    First, create a UINib object for each XIB file you want.

    // Loads a NIB file without instantiating its contents.
    // Simplified here, but to have access to a NIB for the whole lifecycle of the app,
    // create a singleton somewhere.
    static UINib abcuiNib = UINib.FromName("ABCUI", NSBundle.MainBundle);
    

    Second, after you have loaded the NIB into memory, you can now get the objects from it.

    abcuiNib.InstantiateWithOwneroptions(this, new NSDictionary());
    

    Note the “this” parameter. Since it is a view controller you want to load, the above line should be somewhere early in the object’s life cycle, eg in the constructor:

    public partial class ABCViewController : UIViewController
    {
    
        public ABCViewController()
        {
    
            // The first parameter is needed to set an owner (File's Owner) for the objects
            // that will be instantiated.
            // The second parameter is for various options. It does not accept null in MonoTouch,
            // but you can just pass an empty NSDictionary.
            // If you have all your outlets correctly set up, the following line is all 
            // that is needed.
            abcuiNib.InstantiateWithOwneroptions(this, new NSDictionary());
    
        }
    
        // We don't need the following, as it will load the XIB every time
        //public ABCViewController() : base("ABCUI", null) {}
    
    // view controller implementation
    
    }
    

    Mind you, I have not tested the above, as so far I have tested it with various single objects in XIBs. If (and when) I use it with UIViewControllers in XIBs, this is the direction I will move in. I’ll also prepare an article with more in-depth findings and info in due time.

    Also note that the same “rules” apply, eg. you will still have to release all outlets in the ViewDidUnload override.

    If after this, you do not find any improvement in performance, I think you will need to redesign your XIBs. Apple suggests it is better to have multiple XIBs with few objects in each one, instead of few XIBs packed with objects.

    Useful reading: Apple docs on NIB management

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view with a scrollview. I use code to add labels to
I have a form in which I display a bunch of image. I would
I have a silverlight control (View) which displays a list of items in a
I use the following to display scrollview and pagecontrol scrollView=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320,
I have a layout which contains a ScrollView which contains various components including an
I use the following code to load an image into an scroll view. The
I have a scrollView (width:320px height:100px) on my UIView, inside it I add 10
i got a listbox with items and i use datatemplate to display the items
I want to use the scrollview as something like a picker in horizontal mode.
For an Android application, I'm trying to use a Spinner which, when an option

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.