在iOS中是否有类似NSButtonCell的UIButtonCell

时间:2013-12-06 02:41:18

标签: ios objective-c uibutton

如果我想在视图中制作10X10按钮,简单的方法是制作100个按钮, 在Cocoa中可以使用NSButtonCell,所以在iOS中有类似的东西吗?

1 个答案:

答案 0 :(得分:0)

您可以创建自定义单元格

  1. 使用按钮拖放tableView单元格并进行设计 和
  2. 在cellForRowAtIndexPath中添加自定义tableView单元格,如下所示,

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

    {

        static NSString *yourCustomeCelldentifier = @"CustomeTableCell";
        yourCustomeCell *cell = (yourCustomeCell *)[tableView dequeueReusableCellWithIdentifier:yourCustomeCelldentifier];
    
        if (cell == nil)
        {
            NSArray *nib;
            nib = [[NSBundle mainBundle] loadNibNamed:@"CustomeCell_Nib" owner:self options:nil];                   
            cell = [nib objectAtIndex:0];
        }              
    
        return cell;    
    

    }

    希望这种方式可以帮助你