Flexible iOS layouts

I am trying to create a simple flexible layout:

my layout

In my application there is UITextView(a red box) in which there will be a variable amount of text. Below it UIRoundedRectButtonand a UILabel.

I already have text stretch based on the content inside. I was wondering how I can achieve a flexible layout so that the button / tag is pushed automatically if there is a lot of content inside the text.

+3
source share
2 answers
  • Put everything in a different view and set the autoresistor in two orange views so that they have flexible upper margins and a red image, so it has a flexible lower margin. Resize your container when your text changes to be large enough to hold everything.

  • . , . . iOS 5+, , . , .., .

+3

yourViewController viewWillAppear

jus ....

-(void)viewWillAppear:(BOOL)animated
{
 yourTextView.text=yourdata;//here your inserted data ie.. yourdata is string variable

    yourTextView.frame = CGRectMake(yourTextView.frame.origin.x, yourTextView.frame.origin.y, yourTextView.frame.size.width, yourTextView.contentSize.height);

float btnscreen = yourTextView.frame.origin.y + yourTextView.contentSize.height + 15;

yourButton.frame=CGRectMake(yourButton.frame.origin.x, btnscreen, yourButton.frame.size.width, yourButton.frame.size.height);

float lblscreen = yourButton.frame.origin.y + yourButton.frame.size.height + 10;


yourLable.frame=CGRectMake(yourLable.frame.origin.x, lblscreen, yourLable.frame.size.width, yourLable.frame.size.height);
}

, XIB , .m ..... , , , , UIScrollView scrollview, ... , ... :)

0

All Articles