[英]How to resize the programmatically created UILabel,UITextView,UITextfield in programmatically created scroll view as per orientation change
我已經以編程方式創建了scrollview,它會根據方向調整大小。 但是在滾動視圖上創建的UI元素是固定的,它不會更改。 現在,我需要按照以下代碼嘗試嘗試的方向更改UILabel,UITextView,UITextfield的大小,但對我而言不起作用。
CGRect textfieldFrame = CGRectMake(12.0, 20.0, textView.frame.size.width-20, textView.frame.size.height-424);
//CGRect textfieldFrame = CGRectMake(12.0, 20.0, 270, 35);/* I used For fixed size
UITextField *textField = [[UITextField alloc] initWithFrame:textfieldFrame];
[textField setAutoresizesSubviews:YES];
[textField setAutoresizingMask:
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight];
textField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
現在,我必須根據方向更改來調整元素的大小。 如何解決這個問題呢?
嘿Anupama試試這個
UIInterfaceOrientation orientation = [UIApplication
sharedApplication].statusBarOrientation;
if(orientation == UIInterfaceOrientationLandscapeRight ||
orientation == UIInterfaceOrientationLandscapeLeft)
{
// your frame for landscape
}
else if(orientation==UIInterfaceOrientationPortrait)
{
// your frame for portrait
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.