2016-04-25 73 views
0

是否可以在iPhone中将行和列添加到UITableview中,如下所示?在UITableView中添加行和列iOS

请帮助我,我是iOS开发新手。

enter image description here

+1

IM没见过的兄弟 –

+0

https://www.google.co.in/search?q=columns+and+rows+in+android+app&client=ubuntu&hs=任何链接或图片Ftg&channel = fs&source = lnms&tbm = isch&sa = X&ved = 0ahUKEwiN5uXh1qnMAhWEnJQKHTqNBSwQ_AUICCgC&biw = 1615&bih = 955#imgrc = hEitnf9Wwc8WTM%3A –

+0

请找到链接。它看起来应该类似 –

回答

0
I found the answer. 

UIView *newView124=[[UIView alloc]initWithFrame:CGRectMake(224, 90, 2, 48)]; 
    newView124.backgroundColor=[UIColor grayColor]; 
    [cell addSubview:newView124]; 

    //Initialize Label 
    NSLog(@"cell width: %f",cell.frame.size.width); 
    UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 90, 100, 50)]; 
    [lbl1 setFont:[UIFont fontWithName:@"FontName" size:12.0]]; 
    [lbl1 setTextColor:[UIColor blackColor]]; 
    lbl1.text = @"1"; 
    [cell addSubview:lbl1]; 

    UIView *newView=[[UIView alloc]initWithFrame:CGRectMake(40, 90, 2, 48)]; 
    newView.backgroundColor=[UIColor grayColor]; 
    [cell addSubview:newView]; 

    UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectMake(42, 90, 130, 50)]; 
    [lbl2 setFont:[UIFont fontWithName:@"FontName" size:12.0]]; 
    [lbl2 setTextColor:[UIColor blackColor]]; 
    lbl2.text = @"Hospitsal"; 
    [cell addSubview:lbl2]; 

    UIView *newView1=[[UIView alloc]initWithFrame:CGRectMake(172, 90, 2, 48)]; 
    newView1.backgroundColor=[UIColor grayColor]; 
    [cell addSubview:newView1]; 



    UILabel *lbl21 = [[UILabel alloc]initWithFrame:CGRectMake(174, 90, 50, 50)]; 
    [lbl21 setFont:[UIFont fontWithName:@"FontName" size:12.0]]; 
    [lbl21 setTextColor:[UIColor blackColor]]; 
    lbl21.text = @"Active"; 
    [cell addSubview:lbl21]; 

    UIView *newView12=[[UIView alloc]initWithFrame:CGRectMake(224, 90, 2, 48)]; 
    newView12.backgroundColor=[UIColor grayColor]; 
    [cell addSubview:newView12]; 


    UIButton *modeButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 100, 30, 25)]; 


    UIImage *ddd=[UIImage imageNamed:@"pencil.png"]; 

    [modeButton setImage:ddd forState:UIControlStateNormal]; 
    ///[btnEdit addTarget:self action:@selector(imSelected) forControlEvents:UIControlEventTouchUpInside]; 

    [cell addSubview:modeButton]; 
    // [cell.contentView bringSubviewToFront:btnEdit]; 



    UIView *aView1=[[UIView alloc]initWithFrame:CGRectMake(0, 135,self.view.frame.size.width, 2)]; 
    aView1.backgroundColor=[UIColor grayColor]; 
    [cell addSubview:aView1]; 
+0

添加此行以释放内存,创建 –

+0

(UIView * eachView in [cell subviews]) [eachView removeFromSuperview]; –

+0

在添加主代码之前,请在注释中添加代码。 –