0

我正在开发一个 iphone 应用程序,因为我有如下模板所示的要求在此处输入图像描述

4

2 回答 2

0

您可以添加创建UIButton并将它们添加到单元格中,如subView:cellForRowAtIndexPath方法。您可以子类UITableViewCell和 init 方法创建一个 UIButton 并添加到 subView。您还可以通过 xib 创建单元格并动态加载它们。自定义教程UITableViewCell http://www.appcoda.com/ios-programming-customize-uitableview-storyboard/

于 2013-11-11T12:43:27.433 回答
0

这完全取决于您的编码。您需要在如下方法中编写表格视图单元格的逻辑:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        UILabel *lblTeam = (UILabel*)[cell viewWithTag:321];
        UILabel *lblCRank = (UILabel*)[cell viewWithTag:258];
        UILabel *lblPRank = (UILabel*)[cell viewWithTag:369];

*// You can set the CGRectMake co-ordinates using variable like CGRectMake((x+12), (y+3), 120, 15); below  *

        if(!lblTeam){
            lblTeam = [[UILabel alloc]initWithFrame:CGRectMake(110, 52, 120, 15)];
            lblTeam.backgroundColor = [UIColor clearColor];
            lblTeam.textColor = [UIColor colorWithRed:103/255.0 green:103/255.0 blue:103/255.0 alpha:1.0];
            lblTeam.tag = 321;
            lblTeam.font = [UIFont fontWithName:@"Futura-Medium" size:12.0];
            [cell addSubview:lblTeam];
            [lblTeam release];

            lblCRank = [[UILabel alloc]initWithFrame:CGRectMake(110, 19, 150, 25)];
            lblCRank.backgroundColor = [UIColor clearColor];
            lblCRank.textColor = [UIColor colorWithRed:245/255.0 green:168/255.0 blue:0/255.0 alpha:1.0];
            lblCRank.tag = 258;
            lblCRank.font = [UIFont fontWithName:@"Futura-Medium" size:14.0];
            [cell addSubview:lblCRank];
            [lblCRank release];

            lblPRank = [[UILabel alloc]initWithFrame:CGRectMake(187, 20, 40, 25)];
            lblPRank.backgroundColor = [UIColor clearColor];
            lblPRank.textColor = [UIColor colorWithRed:245/255.0 green:168/255.0 blue:0/255.0 alpha:1.0];
            lblPRank.tag = 369;
            lblPRank.font = [UIFont fontWithName:@"Futura-Medium" size:12.0];
            [cell addSubview:lblPRank];
            [lblPRank release];

        }
        //Set the values of the labels or buttons here-
        [lblPRank setText:@""];
        [lblCRank setText:@""];
        lblTeam.text = [countryName uppercaseString];
        return  cell;
   }

如果您仍然遇到任何问题,请向我们展示您正在尝试的代码,我们可以为您提供更好的帮助。

于 2013-11-11T12:54:53.743 回答