Multiple Views in single content view

14 views
Skip to first unread message

NahuelChaves

unread,
Nov 23, 2009, 9:05:43 PM11/23/09
to Cappuccino & Objective-J
Someone knows how to create multiple views to show on a single content
view.. changing between them by the sidebar menu. Im learning
cappuccino but this is difficult!

Elias

unread,
Nov 24, 2009, 4:58:17 AM11/24/09
to Cappuccino & Objective-J
You could create some views with the same size and same position like
"a stack of paper".
Then with your sidebar's button actions you decide which views should
hide and which view should show, for example

- (void)showTheFirstView:(id)sender
{
[view1 setHidden:NO];
[view2 setHidden:YES];
[view3 setHidden:YES];
}

and so on...

Nahuel Chaves

unread,
Nov 24, 2009, 10:26:18 AM11/24/09
to objec...@googlegroups.com
Nice way of seeing it :) but i still have a question... can i create views with its subviews in a separate file? im trying to make my code clean.

2009/11/24 Elias <elia...@gmail.com>
--

You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To post to this group, send email to objec...@googlegroups.com.
To unsubscribe from this group, send email to objectivej+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objectivej?hl=en.



Nahuel Chaves

unread,
Nov 24, 2009, 12:25:59 PM11/24/09
to objec...@googlegroups.com
i was thinking... creating a CPObject named windowManager or something like that.. and creating the views once is "init" but in different methods... something like
-(id) createView1
{
 //add the subviews
}

and then show them by the code you wrote...

makes sense?

2009/11/24 Nahuel Chaves <nahuel...@gmail.com>

Elias

unread,
Nov 24, 2009, 4:36:15 PM11/24/09
to Cappuccino & Objective-J
Of course that's possible

You just make a new class like myCoolView.j

_______________________________________________________

@implementation myCoolView : CPView
{
}

- (void)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:aFrame];
if (self) {
// For example
[self setBackgroundColor:[CPColor
colorWithHexString:@"003366"];
}
return self
}

@end
_______________________________________________________



Then in your AppController you first have to import that file with

@import "myCoolView.j"

and then just add it to you subview like

var myCoolView = [[myCoolView alloc] initWithFrame:CGRectMake(10, 10,
100, 100);
[contentView addSubview:myCoolView];


Hope that helps.


Elias


On 24 Nov., 18:25, Nahuel Chaves <nahuel.cha...@gmail.com> wrote:
> i was thinking... creating a CPObject named windowManager or something like
> that.. and creating the views once is "init" but in different methods...
> something like
> -(id) createView1
> {
>  //add the subviews
>
> }
>
> and then show them by the code you wrote...
>
> makes sense?
>
> 2009/11/24 Nahuel Chaves <nahuel.cha...@gmail.com>
>
>
>
> > Nice way of seeing it :) but i still have a question... can i create views
> > with its subviews in a separate file? im trying to make my code clean.
>
> > 2009/11/24 Elias <elias....@gmail.com>
>
> > You could create some views with the same size and same position like
> >> "a stack of paper".
> >> Then with your sidebar's button actions you decide which views should
> >> hide and which view should show, for example
>
> >> - (void)showTheFirstView:(id)sender
> >> {
> >>   [view1 setHidden:NO];
> >>   [view2 setHidden:YES];
> >>   [view3 setHidden:YES];
> >> }
>
> >> and so on...
>
> >> On 24 Nov., 03:05, NahuelChaves <nahuel.cha...@gmail.com> wrote:
> >> > Someone knows how to create multiple views to show on a single content
> >> > view.. changing between them by the sidebar menu. Im learning
> >> > cappuccino but this is difficult!
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Cappuccino & Objective-J" group.
> >> To post to this group, send email to objec...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> objectivej+...@googlegroups.com<objectivej%2Bunsubscribe@googlegrou ps.com>
> >> .
Reply all
Reply to author
Forward
0 new messages