나는 뷰가 있으며 다른 위치 프레임이있는 많은 UILabel 텍스트가 필요하므로 프로그래밍 방식으로 UILabel을 만들고이를 매개 변수 전달이라고하며 매개 변수 전달을 통해 호출하고 있습니다.다른 UIOrientation에서 UILabel에 대한 위치를 설정하는 방법
아래 코드를 사용하여 가로보기 모드로 회전하면 세로보기 레이블이 계속 표시됩니다. 어떻게 이것을 극복 할 수 있습니까? 아래 코드에서 수행해야합니다. 레이블 프레임의 위치를 세로보기에서 가로보기로 변경하고 싶습니다.
참고 : 매개 변수 전달을 사용하므로 많은 레이블을 만들어야하므로 각 레이블을 만드는 데 많은 방법을 쓸 필요가 없습니다.
-(UILabel*)createLabel:(CGRect)frame :(NSString*)labelTitle
{
UILabel *myLabel = [[UILabel alloc] initWithFrame:frame];
[UIFont fontWithName:@"Arial" size:13];
myLabel.text = labelTitle;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self.view addSubview:[self createLabel:CGRectMake(450,140,60,20):@"Ratings:"]];
[self.view addSubview:[self createLabel:CGRectMake(450,170,60,20):@"Reviews:"]];
}
else
{
[self.view addSubview:[self createLabel:CGRectMake(650,140,60,20):@"Ratings:"]];
[self.view addSubview:[self createLabel:CGRectMake(650,170,60,20):@"Reviews:"]];
}
return YES;
}
'[self facepalm]; ' –