title: How to duplicate UIView infinite times
body: <p>In my app, there is a portion that has to be repeated during a button press. That is, a UIView, that has a couple of text fields, that should repeat infinitely as long as a button is pressed,. To better understand it, I am uploading a "demo view" of the page and the code I used to implement it. I was able to duplicate the view and the label, but the UIButton is not repeated.<a href="https://i.stack.imgur.com/vgLlH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vgLlH.png" alt="First Image, with the button name &quot;Repeat&quot;"></a>
  <a href="https://i.stack.imgur.com/d7p6x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d7p6x.png" alt="Second Image. Label- &quot;Here&quot; has appeared but the button has not"></a></p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      _testView.backgroundColor=[UIColor blackColor];
      [_testView addSubview:_labelRef];
      [_testView addSubview:_buttonRef];
      [self.view addSubview:_testView];
      _lastView=_testView;
          _archievedData=[NSKeyedArchiver archivedDataWithRootObject:_testView];
  
      // Do any additional setup after loading the view.
  }
  
  - (IBAction)repeatButton:(id)sender {
  
      UIView *newView=[NSKeyedUnarchiver unarchiveObjectWithData:_archievedData];
      CGRect newFrame;
      newFrame.origin.x=newView.frame.origin.x;
      newFrame.origin.y=(newView.frame.origin.y + newView.bounds.size.height);
      newFrame.size.height=newView.frame.size.height;
      newFrame.size.width=newView.frame.size.width;
      newView.frame=newFrame;
      newView.backgroundColor=[UIColor greenColor];
      [self.view addSubview:newView];
      _archievedData=[NSKeyedArchiver archivedDataWithRootObject:newView];
  }
  </code></pre>
  
  <p>How can I fix this?</p>