views:

186

answers:

1

I need add to my active main view a new subview. And this subview should be with all content which placed on main view. Subview has a frame = view.frame / 2. I trying implement some solutions (below), but there are no results ((

First off

     CGRect frame = CGRectMake(100, 140, 250, 250);

UIView *view = [self.view copy]; view.frame = frame;

[self.view addSubview:view ]; [view release];

Then

 UIView *View = [[[NSBundle mainBundle] loadNibNamed:@"CurrentTemplate" owner:self options:nil] objectAtIndex:0];

View.frame = CGRectMake(100, 140, 250, 250); [self.view addSubview:view ]; [view release];

Any ideas?

A: 

Hi,

If I understand your question correctly, you want to move all the subviews of self.view into a new view and then add that new view back into self.view?

Perhaps something like this might do it:

// Create a new empty view
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 140, 250, 250)];

// Add each of the children to this new view
NSArray *views = [NSArray arrayWithArray:self.view.subviews];
for (UIView *child in views)
  [view addSubview:child];

// Add the new view as the child of self.view
[self.view addsubview:view];
[view release];

Hope this helps,

Sam

deanWombourne