I am using the following code to for Creating UILabels and calling it by paramater passing. I am using UIViewAutoSizingMask for autosize of labels when rotated in different orientation.
[self.view addSubview:[self createLabel:CGRectMake(450,240,60,20):@"Ratings:"]];
[self.view addSubview:[self createLabel:CGRectMake(450,270,60,20):@"Reviews:"]];
[self.view addSubview:[self Label:CGRectMake(505,240,60,20):aRequests.ratings]];
[self.view addSubview:[self Label:CGRectMake(510,270,60,20):aRequests.reviews]];`
self.view1.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin |UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
-(UILabel*)createLabel:(CGRect)frame :(NSString*)labelTitle
{
UILabel *myLabel = [[UILabel alloc] initWithFrame:frame];
[UIFont fontWithName:@"Arial" size:13];
myLabel.textAlignment = UITextAlignmentLeft;
myLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;
myLabel.text = labelTitle;
[myLabel autorelease];
return myLabel;
}
In Portrait view it displays like this,
Ratings:3
Reviews:4
whereas, When rotated to landscape it display like this.
Ratings: 3
Reviews: 4
There is a space provided after “Ratings” Label. I have used all Autoresizing mask still its not working.
can anyone suggest anyone what is happening and what changes should be done in the above code.I tried all the autoresizeingMask everything but still i am not able to fix this.
The masks are conflicting eachother, use:
and