-1

In my nib file there are three views, I don't show all of them at the same time.

Please take a look at this picture : enter image description here

of course the real situation is more complicated than this picture because i have other subviews (buttons , labels ...) in each view.

actually it is very hard to maintain this file because all the views override each other !

is there any suggestion ?

thank you

user3516596
  • 339
  • 5
  • 14
  • What's the question? What were you _originally_ trying to do before you got yourself into this situation? – matt May 04 '14 at 18:10
  • Do you always show exactly one of them at a time? Do you sometimes show two of them and sometimes three of them? Suggested solutions will depend upon knowing what you're up to. – matt May 04 '14 at 18:12
  • @matt , yes that is right sometimes I show two of them and some times one of them. – user3516596 May 04 '14 at 18:21
  • so for example if I want to change the location of one of the subview in one of this views, may I should move a lot of other subviews.. – user3516596 May 04 '14 at 18:23
  • also it is very hard to see all of this views one override the other – user3516596 May 04 '14 at 18:25
  • why don't you hide unnecessary views and adjust the required views using `setFrame`? – Fahim Parkar May 04 '14 at 18:38
  • Is the problem in your _program_ (managing the views) or is just that right now they are hard to see when designing the interface because they are in the same _nib_? Still not clear what the problem is. – matt May 04 '14 at 18:48
  • exactly ... that is my problem – user3516596 May 04 '14 at 18:51
  • Which one? I gave you two different choices!! I ask "problem 1 or problem 2" and you say "yes"??? Try to be helpful please. – matt May 04 '14 at 18:57
  • aaa sorry ,,, hard to see when designing the interface... – user3516596 May 04 '14 at 18:58

2 Answers2

0

Well in this case below is what I would have done.

My assumption is all three views are of size 320 x 480 (considering iPhone 4)

let's say you have three views as below.

  1. View 1 >> view001
  2. View 1 >> view001
  3. View 1 >> view001

What I would do is add a scrollview mainScrollView.

Now let's consider you want to show view001 only.

- (void) showView001Only {
    view001.hidden = NO;
    view002.hidden = YES;
    view003.hidden = YES;
    mainScrollView.hidden = YES;
}

Now let's say you want to show two views as view002 and view003. In this case I would have added both views in scroll view and add one below each other.

- (void) showView0023Only {
    view001.hidden = YES;
    view002.hidden = NO;
    view003.hidden = NO;
    mainScrollView.hidden = NO;
    [mainScrollView addSubview:view002];
    view002.frame = CGRectMake(0,0,320,480);
    [mainScrollView addSubview:view003];
    view003.frame = CGRectMake(0,480,320,480);
    // now set mainscrollview content size to 320x960
    [mainScrollView setContentSize: CGSize(320, 960)];
}

I hope this is what you are looking for.

If you want to show both views on same screen without scrolling then I would say its all depend on what you have in view1 and view2.

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • thank you for your response, but actually that not my problem I can hide and show them, my problem that it is hard to see them and adjust them in the xib interface.... do you have any other suggestions ! thank you – user3516596 May 04 '14 at 18:57
  • @user3516596 : could you please explain what exactly you want to do? may be we can help you in that way... edit the question and add what you exactly want to do... giving just example is not clear with us... – Fahim Parkar May 04 '14 at 18:58
  • How could I disparate the three views in three nib files with one controller !! – user3516596 May 04 '14 at 19:05
0

Your question is unclear, but I'm going to assume that you mean you are having trouble managing the views while designing them in the nib file.

If so, I have two possible suggestions.

  • In your screen shot, all three views are listed at the left (View, View, View). When you want to work on one of them, drag its "View" listing to the bottom of the list. This brings the view in question to the front so you can work on it and its subviews.

  • This is what I would do: keep each view in its own nib! That way you can design it without the others in your way. When the app launches, use code to load all three nibs in turn, pulling each view out and sticking it into your real interface.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Here are my instructions for how to make a nib that contains just a UIView (and its subviews) and how to load it in code and stick it into your interface: http://www.apeth.com/iOSBook/ch07.html#_outlet_connections – matt May 04 '14 at 19:01