【问题标题】:way to call - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section without reloading调用方式 - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 无需重新加载
【发布时间】:2012-03-07 08:35:57
【问题描述】:

我已经完成了:

[tableView setNeedsLayout][tableView setNeedsDisplay],但是这不会调用该委托。有没有办法在不重新加载数据的情况下重新布局tableView(即:调用reloadData)

【问题讨论】:

    标签: iphone objective-c ios ipad


    【解决方案1】:

    试试:

    [tableView beginUpdates];
    //do stuff...
    [tableView endUpdates];
    

    【讨论】:

      【解决方案2】:

      您的需求究竟是什么。那么只有我们才能帮助您。

      您是否执行过以下步骤来启动 UITableView 的委托

      1.包括 UITableViewDelegate 和 UITableViewDataSource 2.将您的 tableViewDelegate 和数据源链接到 Interface Builder 中的 Files Owner

      如果你想调用你的 tableview 委托方法意味着,

      [table reloadData] 
      

      想知道您是否需要进一步说明

      【讨论】:

        【解决方案3】:

        这里列出了您可以用来仅影响表的一部分的方法。

        插入、删除和移动行和节:

         - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
         - (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
         - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
         - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
         - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
         - (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
        

        重新加载:

         - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;
         - (void)reloadSectionIndexTitles;
         - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation;
        

        别忘了把你的代码放进去

        [tableView beginUpdates];
        //do stuff...
        [tableView endUpdates];
        

        按照@Wise Shepherd 的建议阻止,以避免tableView 的失禁状态和index out of bounds 异常。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-06-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多