> For the complete documentation index, see [llms.txt](https://gitbook.existorlive.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.existorlive.cn/ios/ui/uikit/uitableview/uitableview-de-jia-zai-guo-cheng.md).

# UITableView的加载过程

> `UITableView`有一个UITableViewDelegate对象和UITableViewDataSource对象，我们通过研究这两个对象的方法的调用过程来研究UITableView的加载过程

* **首次加载和调用reloadData**

> `UITableView`的首次加载，其实就是`UITableView`调用`reloadData`之后的结果。

1. 首先会调用`numberOfSectionsInTableView:`获取section的数量
2. 然后调用`tableView:numberOfRowsInSection:`获取section中row的数量
3. 接着加载cell视图，`tableView:cellForRowAtIndexPath:`获取cell，`tableView:heightForRowAtIndexPath:`获取cell的高度。（这里仅加载需要显示的cell）
4. 最后加载section的header view和 footer view。先获取高度，`tableView: heightForHeaderInSection:`,再获取视图,`tableView:viewForHeaderInSection:`

***

* **滑动UITableView**

> 滑动`UITableView`的过程其实就是将不可见的cell加载出来的过程。因此在这个过程中，仅会与cell和header view ，footer view加载的方法。`tableView:cellForRowAtIndexPath:tableView:heightForRowAtIndexPath:tableView: heightForHeaderInSection:tableView:viewForHeaderInSection:`

***

* **插入和删除cell**

>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gitbook.existorlive.cn/ios/ui/uikit/uitableview/uitableview-de-jia-zai-guo-cheng.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
