Reputation: 1067
I have been searching the internet for answers but it seems that I can't any answers. Well, what I have been trying to do is to move a UIButton dynamically based on the what the height of a textfield is.
For example, I have this: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
Of course the textfield will increase it's height based on this code I found.
CGRect frame = txtCardOffer.frame;
frame.size.height = txtCardOffer.contentSize.height;
txtCardOffer.frame = frame;
And to increase UiScrollView height,
CGFloat scrollViewHeight = 0.0f;
container.showsHorizontalScrollIndicator = NO;
container.showsVerticalScrollIndicator = NO;
for (UIView* view in container.subviews)
{
if (!view.hidden)
{
CGFloat y = view.frame.origin.y;
CGFloat h = view.frame.size.height;
if (y + h > scrollViewHeight)
{
scrollViewHeight = h + y;
}
}
}
container.showsHorizontalScrollIndicator = YES;
container.showsVerticalScrollIndicator = YES;
[container setContentSize:(CGSizeMake(container.frame.size.width, scrollViewHeight))];
Everything's now set except for the submit button. I don't know how to make that button change it's vertical position based on the textfield's height. It's just there in the middle. As if it's using position:absolute on CSS.
Can you guys help me out? Am running out of keywords for searching on Google.
Upvotes: 2
Views: 991
Reputation: 4480
try setting button's frame as
[btn setFrame : CGRectMake(x, txtCardOffer.frame.origin.y+txtCardOffer.frame.size.height, 30,60)];
Upvotes: 1