相关疑难解决方法(0)

tableFooterView属性不会修复表视图底部的页脚

我在viewDidLoad方法中设置页脚视图:

UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 718, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
self.table.tableFooterView = fView;
Run Code Online (Sandbox Code Playgroud)

不幸的是,页脚没有在(x,y)上面指定的指定中绘制,但是它坚持使用单元格,因此如果表格视图有4个单元格,则页脚将在第5个单元格中绘制.

我甚至尝试过协议方法, tableView:viewForFooterInSection

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
    return fView;
}
Run Code Online (Sandbox Code Playgroud)

问题没有解决,我确定tableFooterView属性应该在表视图底部的页脚视图但我不确定我可能在这里缺少什么?Thanx提前.

uitableview ios

32
推荐指数
4
解决办法
5万
查看次数

endUpdates之后的UITableView部分页脚视图位置

在ios8上,我正在使用核心数据表视图控制器,删除行后,我的部分页脚视图突然一直向下到底部UITableView.当我滚动表格视图时,页脚视图会返回到它的位置.如何解决这个问题,为什么会发生这种情况?

以下是代码以防万一.

- (void)controller:(NSFetchedResultsController *)controller
   didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath
{       
    if (!self.suspendAutomaticTrackingOfChangesInManagedObjectContext)
    {
        switch(type)
        {
            case NSFetchedResultsChangeInsert:
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeDelete:
                [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
                break;

            case NSFetchedResultsChangeUpdate:
                [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;

            case NSFetchedResultsChangeMove:
                [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
                [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
                break;
        }
    }
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
{
    if (self.beganUpdates)
    {
       [self.tableView endUpdates];
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios ios8

18
推荐指数
2
解决办法
4630
查看次数

UITableView页脚的动画问题执行"beginUpdates""endUpdates"时查看

当我用动画改变单元格高度时(使用beginUpdates(),endUpdates())我的部分页脚有一个非常奇怪的动画:它正在桌面视图的底部移动.

这是我能写的最简单的代码

func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
    return "footer"
}

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return cellHeight
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    return tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    tableView.beginUpdates()
    cellHeight += 20;
    tableView.endUpdates()
}
Run Code Online (Sandbox Code Playgroud)

我怎么能避免这个动画问题?

animation footer uitableview ios

5
推荐指数
1
解决办法
1015
查看次数

插入新表行后,UITableView节页脚移动

我有一个显示项目列表的UITableView.表视图控制器具有一组项,这些项在响应来自Web服务的响应时异步更新.这是我的一个例子(在Swift中):

class MyTableViewController : UITableViewController {
    var items: [ItemClass] = []

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("RootCell", forIndexPath: indexPath) as UITableViewCell
        if indexPath.section == 0 {
            let item = items[indexPath.row]
            cell.textLabel!.text = item.name
        }
        else if indexPath.section == 1 {
            // Another section not shown here
        }
        return cell
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望这个表的每个部分都有一个带有按钮的页脚,所以我也包括这个:

    override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let button = UIButton.buttonWithType(.System) as UIButton
        button.setTitle("Add", forState:UIControlState.Normal)
        if section …
Run Code Online (Sandbox Code Playgroud)

uitableview uikit ios

5
推荐指数
1
解决办法
2243
查看次数

标签 统计

ios ×4

uitableview ×4

animation ×1

footer ×1

ios8 ×1

objective-c ×1

uikit ×1