我已經完成了我在xcode 4中的應用程序編碼,但我嘗試在xcode 5上的此代碼在UITableview中發生了很多問題。表格行和表格的內容不可見。通常表格顯示正確,但我設置水平和分隔線在tableview中的子視圖的時間框架只設置行和內容不可見。表視圖不可見
在畫面我是在藍色的tableview設置背景顏色,所以這裏的內容區域僅出現在白色
{
UIView *subView=[[UIView alloc]initWithFrame:CGRectMake(5, 0, 510, ([subViewsDataArr count] * 50) + 10)];
subView.backgroundColor=[UIColor clearColor];
subView.layer.borderWidth = 1;
subView.layer.borderColor = [[UIColor blackColor] CGColor];
subView.layer.cornerRadius=5;
[myCell addSubview:subView];
int y = 5;
for (int j=0; j<[subViewsDataArr count]; j++, y = y+50) {
UIView *cellView =[[UIView alloc] init];
cellView.frame =CGRectMake(5, y, 500, 50);
cellView.backgroundColor =[UIColor clearColor];
[subView addSubview:cellView];
if (j == 0)
{
int x =-1;
UIImageView *horizontalLineImgStart =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 1)];
horizontalLineImgStart.image =[UIImage imageNamed:@"horizontalLine.png"];
[cellView addSubview:horizontalLineImgStart];
UIImageView *seperatorLineImgStart =[[UIImageView alloc] initWithFrame:CGRectMake(x, 0, 1, 50)];
seperatorLineImgStart.image =[UIImage imageNamed:@"seperatorLine.png"];
[cellView addSubview:seperatorLineImgStart];
for (int i=0; i < 8; i++) {
UILabel *cellLbl = [[UILabel alloc] init];
[cellLbl setText:[NSString stringWithFormat:@"%@",[[subViewsDataArr objectAtIndex:j] objectAtIndex:i]]];
cellLbl.textAlignment =UITextAlignmentCenter;
if (i == 0 || i == 1 || i == 4 || i == 5 || i == 6 || i == 7) {
cellLbl.font =[UIFont fontWithName:@"Helvetica Bold" size:12];
cellLbl.numberOfLines =2;
}
else
{
cellLbl.adjustsFontSizeToFitWidth =YES;
cellLbl.font =[UIFont fontWithName:@"Helvetica Bold" size:10];
}
[cellLbl setBackgroundColor:[UIColor clearColor]];
cellLbl.textColor =[UIColor grayColor];
[cellView addSubview:cellLbl];
UIImageView *seperatorLineImg =[[UIImageView alloc] init];
if (i == 0 || i == 1 || i == 2 || i == 5)
{
cellLbl.frame = CGRectMake(x + 1, 5, 55, 40);
seperatorLineImg.frame =CGRectMake(x + 55, 0, 1, 50);
x = x + 55;
}
else if (i == 6 || i == 7)
{
cellLbl.frame = CGRectMake(x + 1, 5, 80, 40);
seperatorLineImg.frame =CGRectMake(x + 80, 0, 1, 50);
x = x + 80;
}
else
{
cellLbl.frame = CGRectMake(x + 1, 5, 60, 40);
seperatorLineImg.frame =CGRectMake(x + 60, 0, 1, 50);
x = x + 60;
}
seperatorLineImg.image =[UIImage imageNamed:@"seperatorLine.png"];
[cellView addSubview:seperatorLineImg];
}
UIImageView *horizontalLineImgEnd =[[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 500, 1)];
horizontalLineImgEnd.image =[UIImage imageNamed:@"horizontalLine.png"];
[cellView addSubview:horizontalLineImgEnd];
}
else
{
int x =-1;
UIImageView *horizontalLineImgStart =[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 1)];
horizontalLineImgStart.image =[UIImage imageNamed:@"horizontalLine.png"];
[cellView addSubview:horizontalLineImgStart];
UIImageView *seperatorLineImgStart =[[UIImageView alloc] initWithFrame:CGRectMake(x, 0, 1, 50)];
seperatorLineImgStart.image =[UIImage imageNamed:@"seperatorLine.png"];
[cellView addSubview:seperatorLineImgStart];
for (int i=0; i < 8; i++ , txtFldTagVal= txtFldTagVal + 1) {
UITextField *cellTxtFld = [[UITextField alloc] init];
cellTxtFld.text =[NSString stringWithFormat:@"%@",[[subViewsDataArr objectAtIndex:j] objectAtIndex:i]];
cellTxtFld.textAlignment =UITextAlignmentCenter;
cellTxtFld.font =[UIFont fontWithName:@"Helvetica Bold" size:12];
[cellTxtFld setBackgroundColor:[UIColor clearColor]];
cellTxtFld.textColor =[UIColor brownColor];
cellTxtFld.tag =5000 + txtFldTagVal;
cellTxtFld.delegate =self;
cellTxtFld.adjustsFontSizeToFitWidth = YES;
[cellView addSubview:cellTxtFld];
UIImageView *seperatorLineImg =[[UIImageView alloc] init];
if (i == 0 || i == 1 || i == 2 || i == 5)
{
cellTxtFld.frame = CGRectMake(x + 1, 5, 55, 40);
seperatorLineImg.frame =CGRectMake(x + 55, 0, 1, 50);
x = x + 55;
}
else if (i == 6 || i == 7)
{
cellTxtFld.frame = CGRectMake(x + 1, 5, 80, 40);
seperatorLineImg.frame =CGRectMake(x + 80, 0, 1, 50);
x = x + 80;
}
else
{
cellTxtFld.frame = CGRectMake(x + 1, 5, 60, 40);
seperatorLineImg.frame =CGRectMake(x + 60, 0, 1, 50);
x = x + 60;
}
seperatorLineImg.image =[UIImage imageNamed:@"seperatorLine.png"];
[cellView addSubview:seperatorLineImg];
}
UIImageView *horizontalLineImgEnd =[[UIImageView alloc] initWithFrame:CGRectMake(0, 50, 500, 1)];
horizontalLineImgEnd.image =[UIImage imageNamed:@"horizontalLine.png"];
[cellView addSubview:horizontalLineImgEnd];
}
}
}
用一些參考清楚地解釋你的查詢,然後只有你應該得到任何幫助。 – Ganapathy
我創建表視圖與horizondal和分隔線圖像,時間表框架添加任何可見。 –
如果我在表視圖中設置子視圖時間只有表視圖不可見。 –