【问题标题】:How to add textfields on uicollection view?如何在 uicollectionview 上添加文本字段?
【发布时间】:2013-06-14 15:50:28
【问题描述】:

我正在做一个项目,我必须展示这样的视图我尝试使用表格视图,但我无法实现,之后我决定在集合视图的帮助下实现这个。发生了。我在这里感到沮丧,因为我的视图不会发生任何事情。这些是添加到视图上的文本字段,所有内容都是可点击的,任何人都可以帮助我,我是一个新手,所以请帮助我。

【问题讨论】:

  • 我认为这可以在 Grouped tableView 的帮助下完成。检查文档developer.apple.com/library/ios/#documentation/userexperience/…
  • 这可以使用 tableview 来完成,自定义其单元格。
  • @Norbert 我在表格视图的帮助下尝试过,但无法实现。请给我一些其他建议
  • @steve Jobs 我试过了,它还告诉我如何添加不同的文本字段以及那些应该是响应式的
  • 您可以在表格视图中拥有一个自定义单元格。基本上你需要根据你的要求在每个单元格中添加 8 个文本字段,假设所有字段都是可编辑的。您可以查看appcoda.com/customize-table-view-cells-for-uitableview 以创建自定义单元格。这只是一个例子。您可以根据需要创建自己的。

标签: iphone tableview collectionview


【解决方案1】:
    //////////////////
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        if(section==0)
        {
            return self.view_header;
        }

        return nil;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        CGFloat height =0.00;

        if(section==0)
        {
            height = 32;
        }     

        return height;
    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    {    

        if(indexPath.section == 1)
        {
            return 51; 
        }
        else
        {
            return 35;
        }
    }



    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

        if(self.flag_loadCompleted == TRUE)
        {
            return 1;
        }
        return 2;
    }


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  

        if(section == 0)
        {
            return [self.arr_data count];
        }
        else if(section == 1)
        {
            return 1;
        }

        return 0;
    }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    

    static NSString *CellIdentifier = @"MyTemplate";
    MyFinancialTemplate *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
    {
        cell = [MyFinancialTemplate createNewTextCellFromNib];
    }    
    cell.index = indexPath.row;  
    if(indexPath.section == 0)
    {
        cell.index = indexPath.row;
        cell.flag_loader = FALSE;

        cell.selectionStyle = UITableViewCellSelectionStyleGray;
    }
    else
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.flag_loader = TRUE;
    }

    [cell LoadCell];

    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   

}

【讨论】:

  • 好的,我会试试这个。谢谢你的帮助,请告诉我如何从每个文本字段中获得响应。
  • 使用文本字段的代表
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-18
相关资源
最近更新 更多