0

I am trying to add more textfields in my View, Textfield is getting added but the button is not changing the frame . And its gone inside the uitextfield which i have added . Please let me know where i am getting wrong . Thanks I am sharing the code snippet here itself.

-(IBAction)addMore:(id)sender {
UITextField *moreText = [[UITextField alloc] initWithFrame:CGRectMake(20, textfieldy, 280, 44)];
CGRect buttonFrame = self.addmore.frame;
buttonFrame.origin.y += 10;
self.addmore.frame = buttonFrame;
textfieldy = textfieldy + 52;
addMorey = addMorey + 59;
addChecky = addChecky + 63;
[self.scrollView addSubview:moreText];
scrollView.contentSize = CGSizeMake(self.view.window.frame.size.width, 700);

[self.view setNeedsDisplay];
coreDeviOS
  • 1,468
  • 2
  • 14
  • 27

2 Answers2

0

Well, you should really be using autolayout.

For your current code, there is a good amount of information missing. It looks like you're just adding a small offset to a y origin position, but not considering the height of the text field.

Wain
  • 118,658
  • 15
  • 128
  • 151
0

Use this to set frame...I hope this will help you..

[self.addmore setFrame:CGRectMake([self.addmore.frame.origin.x, self.addmore.frame.origin.y+10, self.addmore.frame.size.width, self.addmore.frame.size.height)];
Arvind Kumar
  • 2,371
  • 1
  • 18
  • 25