2011-11-22 71 views
0

我正在創建一個包含分配給uiimageview的uilabel和uiimage的自定義uiview。我自定義的UIView分配到的UITableView headerview但我只看到的UILabel不是UIImage的......請幫助,這是我的代碼...帶有自定義uiview的UItableview標題視圖?

UIView *containerView1 =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 30)]; 

UILabel *headerLabel1 =[[UILabel alloc]initWithFrame:CGRectMake(75, 4, 300, 20)]; 
    headerLabel1.userInteractionEnabled = YES; 
    headerLabel1.text = [NSString stringWithFormat:@"- Latest update %@ -", now]; 
    headerLabel1.textColor = [UIColor brownColor]; 
    headerLabel1.shadowOffset = CGSizeMake(0, 1); 
    headerLabel1.font = [UIFont boldSystemFontOfSize:13]; 
    headerLabel1.backgroundColor = [UIColor clearColor]; 

    UIImage *image = [UIImage imageNamed:@"line_seperator.png"]; 
    UIImageView *imageView = [ [ UIImageView alloc ] initWithFrame:CGRectMake(0.0, 0.0, 30, 30)]; 

    imageView.image = image; 
    imageView.contentMode = UIViewContentModeScaleAspectFit; 

    [containerView1 addSubview:headerLabel1]; 
    [containerView1 addSubview:imageView]; 
    [containerView1 addSubview:indicator2]; 

    walltable.tableHeaderView = containerView1; 

讚賞任何幫助。

忘了說這個代碼在uitableview加載後執行。

+0

嘗試self.tableView.tableHeadView = containerView1 – Legolas

+0

nop不工作Legolas – stefanosn

回答

0

我找到了。形象不對。該圖像作爲.gif從網上下載。我在Photoshop中打開它並將其保存爲.png,但未正確保存。我在photoshop中創建了一個新圖像,並複製了我在新圖像中的圖像。我將它保存爲.png並且工作正常。