Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS中是否有类似NSButtonCell的UIButtonCell_Ios_Objective C_Uibutton - Fatal编程技术网

iOS中是否有类似NSButtonCell的UIButtonCell

iOS中是否有类似NSButtonCell的UIButtonCell,ios,objective-c,uibutton,Ios,Objective C,Uibutton,如果我想在视图中制作10X10个按钮,简单的方法是制作100个按钮, 在Cocoa中有一个NSButtonCell可以使用,那么在iOS中有类似的东西吗?您可以创建一个自定义单元格 拖放tableView单元格并使用按钮进行设计 及 在cellForRowAtIndexPath中添加自定义tableView单元格,如下所示 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndex

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

您可以创建一个自定义单元格

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

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

    }


    希望这种方式能帮助您

    ui按钮
    NSButton
    NSButtonCell
    之间有什么区别?你到底想干什么?如果要在视图中创建10x10个按钮,可以在故事板上创建,也可以通过编程方式创建100个
    UIButton
    对象来创建。@nhgrif-NSButton可以包含许多nsbuttoncell,每个按钮单元的性能都像一个按钮,而所有单元都只在一个NSButton中,这意味着您只需要一个NSButton.Hrm。听起来像是
    UIButton
    相当于
    NSButtonCell
    then。我不确定在
    iOS
    中是否有类似于
    NSButton
    的东西
    UIButton
    是用于在iOS中制作按钮的类。
    UITableView
    是用于
    UITableViewCells
    的容器,可以使用与按钮相同的方式进行选择。这同样适用于
    UICollectionView
    UICollectionViewCells
    。但是有了这些,您对按钮的放置方式/位置的控制有限,而
    ui按钮可以放置在任何地方。您所说的NSButton不是真的,它只有一个按钮单元。你的意思是一个按钮单元的矩阵,不,在iOS中没有这样的。集合视图可以为您提供一个UIButtons网格,但是集合视图的设置是完全不同的——它不像OSX中的矩阵那样由行和列访问。
    
        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;