IOS teaches you to play Uitableviewcontroller and TableView

Source: Internet
Author: User

The Uitableviewcontroller and TableView in the iphone and ipad development should be more of a control.

But you will be bored by writing these controls too much.

How to make this control work all the time. How to make this control easy to write. is very necessary. In particular, uitableviewcontroller the business logic of Datasouce integration in their own body and let the look of chaos without a chapter.

1. The solution Uitableviewcontroller has been able to use.

That is to write a base class of Uitableviewcontroller, and then other to inherit. This allows similar functionality to be written to the base class.

For example, I created a base class of my own that defines an attribute isscroll used to determine when tableview can scroll.


Then we can write similar functions in the. m file. For example, when there is no data to display a temporary no data or data loaded in the picture.

TableView more out of the place show blank and so on.



And then the other inheritance has a similar trait.


2.dataSouce content Integration in Uitableviewcontroller it's too lame.

All we have to do is extract the data.

First of all


Very easy isn't it.


We're going to define a block. You can also use delegate to see people like this block is used to get the cell and differentiate between different cells.


And then the corresponding proxy method to implement it OK

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvd2pzemy=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center ">

Finally, let's see if our uitableviewcontroller really don't need to write these.



It's not like that end. Not a bit of datasource code OH.

Use block to return to the implementation of the cell. Use the keys to differentiate the cell's choice.

Resource http://download.csdn.net/detail/wjszf/7762843

IOS teaches you to play Uitableviewcontroller and TableView

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.