标签: tableviewcell

如何阻止UITableView单元格覆盖内容?

我正在使用UITableView,我注意到我的tableview中的单元格在滚动时逐渐变得更大胆,它覆盖了内容,我想要阻止它,但是看不到我出错的地方.

在我的UITableView上,出于某种原因,当我滚动tableview的内容时,会搞乱手动创建的UILabel.

我需要手动UILabel,因为我需要稍后使用自定义单元格.

当我上下滚动时,标签逐渐变得更大胆,更大胆; 它们总是重叠,有时甚至会影响较低的行(甚至在它们处于视口之前).

如果我继续这样做,细胞内容就会变得难以理解.

仅当backgroundColor未设置为时才会发生这种情况clearColor.

我曾尝试[cellLabel setClearsContextBeforeDrawing:YES];[self.tableView setClearsContextBeforeDrawing:YES]; 没有效果.

如果我使用cell.textLabel.text那么问题似乎消失了.

代码和图像示例如下.

  // Simple table view
    - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }

        // Configure the cell...
        //[self configureCell:cell atIndexPath:indexPath];


        NSString *txt = @"Product";


        //cell.textLabel.text = txt;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;

        UIView *cellView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, cell.frame.size.height)]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview custom-cell tableviewcell ios

11
推荐指数
2
解决办法
3万
查看次数

NSInvalidArgumentException',原因:' - [UITableViewWrapperView indexPathForCell:]

好吧,我有从iOS 6升级到7的问题.iOS 6工作正常,但我在iOS7中收到以下错误

我不确定,但我认为错误发生在这里.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Events Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

// Configure the cell...
Event *event = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = event.name;
return cell;
}
Run Code Online (Sandbox Code Playgroud)

基本上当我调用TableViewCell时,它会调出一个Datepicker但是当我点击"完成"按钮时它会崩溃.有线索吗?

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewWrapperView indexPathForCell:]: unrecognized selector sent to instance 0xc133070'



2013-09-24 17:26:14.056 CRM4Life[36587:a0b] -[UITableViewWrapperView indexPathForCell:]:     unrecognized selector sent to instance 0xc133070
2013-09-24 17:26:14.097 …
Run Code Online (Sandbox Code Playgroud)

datepicker tableviewcell ios7

11
推荐指数
1
解决办法
3715
查看次数

tableviewcell"二元运算符'=='的Parse/Swift问题不能应用于cell类型和nil的操作数"

使用Xcode 6.3 beta时,Parse/Swift存在问题

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath , object: PFObject) -> PFTableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! secTableViewCell

        if cell == nil
        {
            cell = secTableViewCell(style: UITableViewCellStyle.Default , reuseIdentifier: "cell")
        }
        // Configure the cell...

        cell.title.text = (object["exams"] as! String)
        cell.img.image = UIImage(named: "109.png")

        return cell
    }
Run Code Online (Sandbox Code Playgroud)

错误指向

 if cell == nil
        {
            cell = secTableViewCell(style: UITableViewCellStyle.Default , reuseIdentifier: "cell")
        }
Run Code Online (Sandbox Code Playgroud)

二元运算符'=='不能应用于cell类型和nil的操作数"

xcode tableviewcell ios parse-platform swift

10
推荐指数
1
解决办法
1万
查看次数

如何让footerview始终位于UITableViewController的底部?

我正在使用a UITableviewcontroller,我希望页脚视图始终位于屏幕的底部.然而,y所述的位置页脚视图正在改变,因为每heighttableviewcell.我怎么能一直坚持到屏幕的底部?

uitableview tableviewcell ios swift

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

没有可用于tableView的数据时显示自定义标签

有问题的应用程序可以让用户将项目标记为收藏.当用户没有保存的收藏夹时,我想通知他们这个事实(大多数我讨厌空白tableView的想法).

numberOfRowsInSection当没有用户标记为收藏的项目时,我为零.我想设置cell.textLabel.text = @"你没有收藏夹"但是当没有项目cellForRowAtIndexPath没有被调用时.

我可以测试numberOfRowsInSection在遇到0时给出结果然后测试1行cellForRowAtIndexPath然后插入自定义文本但是如果他们只有一个喜欢的话会怎样?

UPDATE

我尝试实现上面的想法,并在下面推荐,但也许我做得不对,可能是因为它是一个fetchedResultsController,其中委托方法在发生更改时更新表.

当表中只有一个单元格删除单元格时,我收到此错误:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UITableView.m:976 Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus …

iphone objective-c uitableview tableviewcell

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

自定义UITableViewCell,单元格中的按钮不起作用

我有一个UITableViewController,我正在使用自定义UITableViewCell.单元格包含图像,标签和按钮.除按钮外,一切都按预期工作.按下按钮时,没有任何反应.只选择了单元格.

我在IB中从按钮到我的自定义TweetTableViewCell类建立了连接.

@property (weak, nonatomic) IBOutlet UIButton *cellFollowButton;
- (IBAction)followButtonTappedonCell:(id)sender;
Run Code Online (Sandbox Code Playgroud)

我在followButtonTappedonCell操作中向控制台写了一些文本.但按下按钮时,没有任何反应.在我看来,某些视图在到达按钮之前消耗了水龙头.让它更混乱...当我在程序中添加一个按钮UITableViewController时,如下所示:

[cell.cellFollowButton addTarget:self action:@selector(customActionPressed) forControlEvents:UIControlEventTouchDown];
[cell addSubview:cell.cellFollowButton];
Run Code Online (Sandbox Code Playgroud)

......它只是有效.我在其他文章中读到,禁用"启用用户交互"解决了类似的问题,但在我的情况下却没有.我确信在UITableViewCells中使用按钮时,许多其他人一定遇到过这个问题.任何帮助都非常感谢.

我正在使用Xcode 5 for iOS 7.

uibutton uitableview tableviewcell ios ios7

9
推荐指数
2
解决办法
9324
查看次数

在pageViewController内的tableView上滑动以删除

我有一个tableView内部,pageViewController当在一个单元格上滑动以显示删除单元格的选项时,只有在某些情况下才能识别出手势,比如说你快速而且积极地滑动.

我想这会发生,因为它不确定滑动手势是用于pageView还是用于tableView.有没有办法专门确定滑动手势发生的位置,以便能够顺利显示删除按钮?

tableview tableviewcell ios uipageviewcontroller swift

9
推荐指数
2
解决办法
1969
查看次数

IOS UITableview如何在表动画完成后采取行动

如何在完成UITableview的动画时采取行动?

我正在尝试缩小UITableview单元格并删除收缩后不可见的单元格子视图.为了缩小单元格,我调用[tableview beginUpdates]和[tableview endUpdates],并更改由UITableview的highForForWowAtIndexPath数据源方法返回的单元格的高度.

挑战是,我需要tableview完成收缩,以便在我删除子视图之前,子视图不在视线范围内.如果我在调用[tableview endUpdates]之后(或之前或之间)放置代码从单元格中删除子视图,那么子视图会很快被删除(它不会等待动画)并且它看起来很有趣.

我的想法是我希望能够设置完成动画后运行的回调,并删除回调中的subView

animation tableview tableviewcell ios

8
推荐指数
1
解决办法
2330
查看次数

勾选静态单元格uitableview

我正在使用UITableView,有3个部分(静态单元格)

  • 货币
  • 语言
  • 社会

它们具有不同的行数:

  • 货币有3行(美元,欧元,日元)
  • 语言有2行(EN,JP)
  • 社交有3行(Twitter,FB,Line)

现在,我默认在每个部分的第一行设置一个复选标记.但是,我想允许用户设置其默认设置,并根据他们设置的内容相应地更改复选标记.

我的问题是如何设置3个不同部分的复选标记,每个部分的行数不同?

我是否需要为每个部分设置一个单元格标识符?我是否还需要为每个部分创建一个UITableViewCell swift文件?

uitableview tableviewcell swift

8
推荐指数
2
解决办法
3118
查看次数

我实现了editActionsForRowAtIndexPath和commitEditingStyle,但在刷单元格时,tableViewCell上没有显示编辑操作

我实现editActionsForRowAtIndexPathcommitEditingStyle轻扫是工作,但没有编辑动作出现在UITableViewCell

我的实施editActionsForRowAtIndexPathcommitEditingStyle如下:

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == UITableViewCellEditingStyle.Delete {
            //I did some work here
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
        }
    }


 func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]?  {

    let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Delete" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
        //I did some work here
        tableView.reloadData()
    })


    return [deleteAction]
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激

uitableview tableviewcell ios swift uitableviewrowaction

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