how to use multiple copies of any Subview(created in xib) from xib file
I am using xib to create view for my project. The condition is:
I have multiple UIView IBoutlet's Object.
IBOutlet UIView *viewOpenDoor;
IBOutlet UIView *viewOpenDoor_Second;
viewOpenDoor is only connected to one of the view in xib. Now i am using
this code to reuse the same view multiple times in viewdidload method-
[viewOpenDoor setFrame:CGRectMake(30, 80, viewOpenDoor.frame.size.width,
viewOpenDoor.frame.size.height)];
[self.view addSubview:viewOpenDoor];
viewOpenDoor.layer.borderColor = [UIColor blackColor].CGColor;
viewOpenDoor.layer.borderWidth = 0.9f;
viewOpenDoor.layer.cornerRadius = 6.0f;
[viewOpenDoor setHidden:YES];
viewOpenDoor_Second = [[UIView alloc] init];
viewOpenDoor_Second = [viewOpenDoor copy];
[viewOpenDoor_Second setFrame:CGRectMake(184, 80,
viewOpenDoor.frame.size.width, viewOpenDoor.frame.size.height)];
[self.view addSubview:viewOpenDoor_Second];
it's giving exception-
-[UIView copyWithZone:]: unrecognized selector sent to instance 0x95ba140
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[UIView copyWithZone:]: unrecognized selector sent to instance
0x95ba140'
So, my question is how can i reuse this one IBOutlet object created in
xib, multiple times with different instances?
No comments:
Post a Comment