首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >生成多维标签

问生成多维标签
EN

Stack Overflow用户
提问于 2015-01-09 14:06:55
回答 1查看 28关注 0票数 0

我想设置二维数组,因为我想知道它表示哪个单元格,以及它为该单元格按下了哪个按钮。我怎样才能做到这一点?

代码语言:javascript
复制
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"SimpleTableCell";

    TimelineTableViewCell *timeLineCell = (TimelineTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(timeLineCell==nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TimelineTableViewCell" owner:self options:nil];
        timeLineCell = [nib objectAtIndex:0];
    }
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 45, 600, 100)];
    scrollView.showsHorizontalScrollIndicator=YES;
    scrollView.delegate=self;
    int i=0;
    UIView *v1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 110*13, 100)];
    for(i=0;i<10;i++)
    {
        UIImageView *imageView1=[[UIImageView alloc]initWithFrame:CGRectMake((i*110),0, 100.0, 100.0)];
        imageView1.image=[UIImage imageNamed:@"alia.png"];
        NSInteger xPos=80+(i*110);
        NSLog(@"xPos:%ld",(long)xPos);
        UIButton *btn1=[[UIButton alloc]init];
        [btn1 setImage:[UIImage imageNamed:@"icon_Cancel@2x.png"] forState:UIControlStateNormal];
        [btn1 setFrame:CGRectMake(xPos, 0, 20, 20)];
        btn1.backgroundColor=[UIColor clearColor];
        [btn1 setTag:i];
        [btn1 addTarget:self action:@selector(cancelEvent:) forControlEvents:UIControlEventTouchUpInside];
        [v1 addSubview:btn1];
        [v1 addSubview:imageView1];

    }

    [scrollView addSubview:v1];
    scrollView.contentSize = v1.frame.size;
    [timeLineCell addSubview:scrollView];

    //set font
    UIFont *font17=[UIFont fontWithName:@"Titillium Web" size:17.0];
    UIFont *font15=[UIFont fontWithName:@"Titillium Web" size:15.0];
    UIFont *font13=[UIFont fontWithName:@"Titillium Web" size:13.0];
    UIFont *font10=[UIFont fontWithName:@"Titillium Web" size:10.0];
    [timeLineCell.lblPostUserName setFont:font17];
    [timeLineCell.lblTime setFont:font13];
    [timeLineCell.lblDate setFont:font13];
    [timeLineCell.lblNoOfLike setFont:font10];
    [timeLineCell.lblNoOfComment setFont:font10];
    [timeLineCell.txtPost setFont:font15];
    /////////////////////////////

    //timeLineCell.image.image=[[UIImage imageNamed:@"back_like_comm@2x.png"]stretchableImageWithLeftCapWidth:5 topCapHeight:5];
    timeLineCell.imgPostUser.layer.cornerRadius=20.0;
    timeLineCell.imgPostUser.layer.masksToBounds=YES;
    timeLineCell.imgPostUser.image=[UIImage imageNamed:@"beuty.png"];

    return timeLineCell;
}
EN

回答 1

Stack Overflow用户

发布于 2015-01-09 14:44:35

子类化UIButton并添加另一个属性来存储列的标记。检索此值以及普通标记的值,以获取row#和col#。就像this一样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27854765

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档