SeungHun Cho
SeungHun Cho

Reputation: 51

Is it possible to show same instance of UIView on multiple views?

Is it possible to show same instance of UIView on multiple views?

I've got a UIView instance,

UIViewController* page01 = [[UIViewController alloc]initWithNibName:@"Page01" bundle:nil];

And I need to display the contents of page01 on multiple views.

I tried below, but it failed. it seems that multiple view instances are needed to display on multiple views.

[self.view01 addSubview:self.page01.view];
[self.view02 addSubview:self.page01.view];

Are there any workarounds? Please give me some hints. Thanks.

Upvotes: 0

Views: 175

Answers (1)

Amin Negm-Awad
Amin Negm-Awad

Reputation: 16660

  1. No, it is not possible. A view is linked into a view hierarchy with one superview only and has a rectangle in that view.

  2. Typically you put the view into a separate nib and load the nib multiple times.

Upvotes: 1

Related Questions