标签: custom-cell

UITableView Custom Cell非常慢

我有一个UITableView,我已经创建了一个自定义单元格来显示我的表格.我显示了6个UILables,虽然我只显示了20个记录,但滚动时速度非常慢.

这就是我的 - tableView:cellForRowAtIndexPath:的样子:

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

    static NSString *CustomCellIdentifier = @"CustomCellIdentifier";

    HistoryCell *cell = (HistoryCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];

    if (cell == nil) { 
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HistoryCell" owner:nil options:nil];

        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[UITableViewCell class]])
                cell = (HistoryCell *) oneObject;
    }

    NSArray *object;
    object = [cours objectForKey: [NSString stringWithFormat:@"%d", indexPath.section]];
    History *rowData = [object objectAtIndex:indexPath.row];

    if (rowData.month == 99) {
        cell.hour.frame = CGRectMake(10, 0, 135, 35);
        cell.data.hidden = YES;
        cell.hour.textColor …
Run Code Online (Sandbox Code Playgroud)

iphone uitableview custom-cell

3
推荐指数
1
解决办法
3059
查看次数

如何在自定义单元格中查找按钮框架的x,y位置

我用自定义单元格创建了一个表视图,如下所示.

![自定义单元格] [1]

![出桌视图] [2]

我需要在每个单元格中使用选择器而不是滑块来设置评级

在此输入图像描述

我需要设置选择器位置,只需按下按钮,它将与按钮位置相对应

如何实现它.

我尝试了fram和bounds如下,但每次都给予相同的vaues

   - (IBAction) buttonClicked:(UIButton *)sender
    {      
          NSLog(@"------%f  %f",sender.frame.origin.x , sender.frame.origin.y); //250, 2

         NSLog(@"------%f  %f",sender.bounds.origin.x , bounds.frame.origin.y); // 0.0 , 0.0

       picker.frame = CGRectMake(sender.bounds.origin.x , sender.bounds.origin.y, 50, 216);
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c frame custom-cell cgrect

3
推荐指数
1
解决办法
2017
查看次数

如何从UITableViewCell获取其他控制值?

我有一个疑问,当我们选择一行或点击按钮时如何获得其他控件的值,同时具有自定义tableViewCell.假设我有一个带有TextField,Slider和按钮的TableView Cell.按钮有动作使用:

btn.tag = indexPath.row;
[btn addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

现在我可以获得其动作方法的按钮.我需要在按钮点击上获取textField的值和滑块的值.

一个选项是我创建一个数组并在该数组中存储这两个控件的值并对其进行管理.但我不认为这是管理它的正确方法.

请导航我以当前的方式获取UITableViewCell的子视图值的值.

谢谢

iphone uitableview custom-cell

2
推荐指数
1
解决办法
9064
查看次数

具有自定义类的原型单元格不会触发init?

我对objective-c很新,对原型单元有疑问.

我有自定义单元格的tableview,它工作得很好.

现在,我也重写我的自定义单元格类-(id)init-(id)initWithStyle: reuseIdentifier:

如果我对单元格进行类检查,它显然属于我的自定义类,但是从未调用过init方法.

所以它为我创造了它们,但不知何故避免了-(id)init对我来说似乎很奇怪的射击.

我想我可以自己创建它们,但它们似乎真的很奇怪它们可以在没有被创建的情况下存在吗?

谢谢!

iphone objective-c uitableview custom-cell uistoryboard

2
推荐指数
1
解决办法
1779
查看次数

如何访问tableview中的单元格?

我是iPhone开发的新手.我遇到了问题.我想在我的UITableView中实现一个复选框功能.但我的UITableViewCells是自定义单元格,由图像和3个UILabel组成.我可以将子视图带到表视图中,以便可以放置复选框图像,并且我成功了.但问题来的是每当我点击图像时,只有最后一个单元格复选框被更改.我想访问我点击的单元格.

我试过这个

    UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath]
Run Code Online (Sandbox Code Playgroud)

但是由于细胞是定制的,因此崩溃了.

任何人都可以建议我这样做的好方法吗?

iphone uitableview custom-cell ios5 xcode4.3

2
推荐指数
1
解决办法
5119
查看次数

GWT如何将自定义单元格添加到celltable/datagrid

我已经渲染了一个自定义单元格,它结合了图像和文本.它看起来像这样:

   class ImageTextCell extends AbstractCell<String> 
Run Code Online (Sandbox Code Playgroud)

我的问题是如何将此单元格添加到celltable/datagrid中.我已经厌倦了.

  Column<Message, String> iconColumn = new Column<Message, String>(new ImageTextCell())
            {
        @Override
        public String getValue(Message versionStatus) {

            return ? // I dont know what to type here. How to return the ImageTextCell object           }
    };
Run Code Online (Sandbox Code Playgroud)

gwt datagrid cell custom-cell gwt-celltable

2
推荐指数
1
解决办法
4121
查看次数

创建自定义tableview分隔符时出错

我正在尝试使用自定义分隔符创建一个tableview.我制作了一个包含内容的自定义Cell,另一个只包含带分隔符的UIImageView.问题在于如何访问内容.我不能使用indexPath.row

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier: @"CustomCell"];
    if(cell == nil) 
    { 
        cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
    }

    SeparatorCell *cellSeparator = (SeparatorCell *) [tableView dequeueReusableCellWithIdentifier: @"SeparatorCell"];
    if(cellSeparator == nil) 
    { 
        cellSeparator = [[[NSBundle mainBundle] loadNibNamed:@"SeparatorCell" owner:self options:nil] objectAtIndex:0];
    }

    if(indexPath.row % 2)
    {
        UIFont * myCustomFont = [UIFont fontWithName:@"Arial Black" size:16];
        [cell.titulo setFont:myCustomFont];
        cell.titulo.textColor = [UIColor colorWithRed:103/255.0f green:169/255.0f blue:0/255.0f alpha:1];

        cell.titulo.text = [Title objectAtIndex:myRow];
        cell.subtitle.text = [Subtitle objectAtIndex:myRow];

        cell.tag …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview custom-cell

2
推荐指数
1
解决办法
5870
查看次数

iOS:在不创建自定义单元格的情况下向UITableViewCell添加第三个标签?

我之前使用过自定义单元格,但我只想添加第三个标签(没有别的!)是否有更简单的解决方案?我想要做的就是显示标题,内容和日期.我已经将前两个设置为textLabels和detailTextLabels,但我当然需要第三个日期.

那么,如果没有自定义单元格,是否有更简单的解决方案?

谢谢

uitableview custom-cell ios

2
推荐指数
1
解决办法
9120
查看次数

UITableViewController 中带有 UISearchController 的自定义单元格(结果控制器)

我正在尝试实现一个 UISearchController(而不是已弃用的 UISearchDisplayController)

我面临着一个可笑的时间进食问题。

当我尝试时,dequeueResusableCellWithIdentifier它不适用于我的CellAutocompletion(UITableViewCell 子类化)

像这样 :

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let item = filteredProducts[indexPath.row]

    let cell:CellAutocompletion = self.tableView.dequeueReusableCellWithIdentifier("suggestionCell") as! CellAutocompletion

    cell.itemLabel?.text = item.item_name;

    return cell
}
Run Code Online (Sandbox Code Playgroud)

这个扔我 fatal error: unexpectedly found nil while unwrapping an Optional value

但是当我这样做时:

    let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "suggestionCell");
Run Code Online (Sandbox Code Playgroud)

有用。因此,对于默认的 iOS 单元,它可以工作,而我的自定义单元则不能。任何的想法?

我想我问了错误的tableview,但考虑到我在另一个VC使用的UISearchController中包含的TableviewController中,我迷路了。

我的主要 VC实例化了我的 searchController 和出现问题的 TableViewController。

    //ViewDidLoad
    resultsTableController = ProductResultTabController();
    resultsTableController.tableView.delegate = self;

    self.searchController = UISearchController(searchResultsController: resultsTableController);
    searchController.searchResultsUpdater …
Run Code Online (Sandbox Code Playgroud)

uitableview custom-cell ios swift uisearchcontroller

2
推荐指数
1
解决办法
1114
查看次数

Swift 3 - 在多个自定义单元格中重用单元格的问题

在 UITableview 中向下滚动时遇到问题。当单元格被重用时,表格向我显示了具有旧内容的单元格。

问题如下:

Swift 想要重用旧单元格,但没有正确清除旧单元格中的旧内容。这会导致单元格具有旧内容,尽管我正在为单元格提供新数据。

UITableView 的架构,如果如下:

  • 每个自定义单元格都有自己的标识符
  • 每个自定义单元格都在一个自己的类中分开

问题截图:

问卷开始截图

截屏

向下滚动的表格

截屏

这里的问题是“Handedness”-Cell,它显示了单元格编号 3(因为单元格的重用),这是不对的

numberOfSection-方法

override func numberOfSections(in tableView: UITableView) -> Int {
    return 2
}
Run Code Online (Sandbox Code Playgroud)

numberOfRowsInSection-方法

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    if(section == 0){
        return questionnaireStructure.count
    } else {
        return 1
    }
}
Run Code Online (Sandbox Code Playgroud)

cellForRowAt 方法

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    // first section is the normal Questionnaire
    if(indexPath.section == 0){

        // current questionnaireStructure
        let …
Run Code Online (Sandbox Code Playgroud)

uitableview custom-cell ios swift

2
推荐指数
1
解决办法
3538
查看次数