2011-09-09 19 views
1

的子類不顯示我有,我想展現一個UIImageView和幾個UILabels自定義視圖(UIView的子類)。 imageView與FaceBook異步傳遞,標籤從特定方法獲取文本。問題在於,即使imageView在到達時呈現成功,標籤也不會顯示。 讓我告訴你的代碼UILabels中的UIView

@interface CustomView : UIView { 

    UIImageView *imageView; 
    UILabel *lbl1; 
    UILabel *lbl2; 
    UILabel *lbl3; 
    UILabel *lbl4; 
} 

@property(nonatomic,retain) UIImageView *imageView; 
@property(nonatomic,retain) UILabel *lbl1; 
@property(nonatomic,retain) UILabel *lbl2; 
@property(nonatomic,retain) UILabel *lbl3; 
@property(nonatomic,retain) UILabel *lbl4; 

和實現如下:

@implementation CustomView 

@synthesize imageView; 
@synthesize lbl1; 
@synthesize lbl2; 
@synthesize lbl3; 
@synthesize lbl4; 

- (id)initWithFrame:(CGRect)frame 
{ 
    if ((self = [super initWithFrame:frame])) 
    { 
     self.lbl1 = [[UILabel alloc] initWithFrame:CGRectMake(65, 356, 98, 13)]; 
     self.lbl1.backgroundColor = [UIColor clearColor]; 
     [self addSubview:self.lbl1]; 

     self.lbl2 = [[UILabel alloc] initWithFrame:CGRectMake(260, 356, 50, 13)]; 
     self.lbl2.backgroundColor = [UIColor clearColor]; 
     [self addSubview:self.lbl2]; 

     self.lbl3 = [[UILabel alloc] initWithFrame:CGRectMake(65, 374, 92, 13)]; 
     self.lbl3.backgroundColor = [UIColor clearColor]; 
     [self addSubview:self.lbl3]; 

     self.lbl4 = [[UILabel alloc] initWithFrame:CGRectMake(260, 374, 49, 13)]; 
     self.lbl4.backgroundColor = [UIColor clearColor]; 
     [self addSubview:self.lbl4]; 
    } 
    return self; 
} 

請注意,標籤矩形硬編碼爲方便和不匹配。 用於設置標籤文本的方法的樣品如下:

- (void)showLbl1:(NSString *)str withFont:(UIFont *)font andColor:(UIColor *)color 
{ 
    self.lbl1.font = font; 
    self.lbl1.textColor = [UIColor cyanColor]; 
    [self.lbl1 setText:str]; 
} 

的圖像與由performSelectorInBackground運行,並與通過performSelectorOnMainThread運行的方法繪製的方法遞送。 最後,整個視圖由addSubView在上海華加入。

Thanx提前

+0

添加標籤爲視圖像這樣子視圖[self.view addSubview:self.lbl4]。 – Prajan

+0

是否showLbl1和這樣的方法被調用? – Madhu

+0

@ozzotto:如果有任何疑問,你能幫我嗎? – Prajan

回答

1

試着畫標籤邊界,看看他們......另外,請檢查你有沒有尤伯杯泄漏,你有一個的alloc init和從未釋放標籤以及使用該二傳手,所以你正在做一個雙重分配初始化。