IOS teaches you how to play with UITableViewController and TableView and iostableview

Source: Internet
Author: User

IOS teaches you how to play with UITableViewController and TableView and iostableview

In iphone and Ipad development, UITableViewController and TableView are usually used. However, you will get bored with writing too much of these controls.

How can I keep this control usable? How can I make it easy to write. Yes. In particular, UITableViewController integrates dataSouce's business logic on itself and makes it look messy.

1. Solve the problem that UITableViewController can be used all the time.

That is, write the UITableViewController of the base class and inherit the other class. In this way, similar functions can be written to the base class.

For example, I created my own base class and defined an attribute isScroll to determine when TableView can be rolled.


Then, we can write similar functions into the. m file. For example, if there is no data, a picture is displayed for the moment or the data is loaded.

A blank area is displayed when multiple tableviews are displayed.



Then other inheritance will have similar features.


2. The integration of dataSouce content in UITableViewController is too frustrating.

We need to extract data.

First


Is it easy.


We also need to define a block. You can also use delegate to look at your personal preferences. This block is used to obtain cells and differentiate various cells.


Then implement the corresponding proxy method.


Finally, let's see if our UITableViewController does not really need to be written.



If this is not found, end is like this. No datasource code. Use block to return the cell implementation. Use keys to Differentiate cell selection.

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


In ios programming, UIview, UItableview, and UIviewcontroller, UItableviewcontroller, and navigationcontroller

UIview is a view, and UIviewcontroller is a view controller;

In short, it is an affiliated relationship. When you create a UIViewController, this UIViewController will bring a UIview, that is, viewController. view,
When we need to create an interface, we often create a view controller instead of a single view. This is to make it easier for us to operate and control this view, such as modal pop-up, use the navigation bar to implement the protocol of various controls.
Hope to help you;

In IOS development, how does Tableviewcontroller adjust the height?

UITableViewController by default, tableView is full screen. You can use UIViewController and add UITableView by yourself.
 

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.