2011-10-19 5 views
1

UILabelを作成するために次のコードを使用し、それをパラメータ渡しで呼び出します。私はUIViewAutoSizingMaskをラベルの自動サイズ変更に使用しています。ポートレートでAutoResizingMaskを使用している場合のUILabelの整列問題

[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; 
} 

はこのような表示の風景に回転したとき、それは、

    Ratings:3 
        Reviews:4 

一方、このように表示するビュー。

 Ratings: 3 
    Reviews: 4 

"評価" ラベルの後に提供スペースがあります。私はすべてのAutoresizingマスクを使用していますが、まだ動作していません。

誰もが何が起こっているのか、上記のコードで何が行われるべきかを誰にも示唆できます。すべての自動サイズ変更マスクを試しましたが、まだ修正できません。

答えて

0

マスクは、お互いに矛盾している使用します。

self.view1.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 

myLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin; 
関連する問題