iOS Development UI article-Direct use of the UITableView Controller

Source: Internet
Author: User
Tags uikit

iOS Development UI article-Direct use of the UITableView Controller

I. GENERAL process

1//2//  YYViewController.h 3//  UITableView Controller 4//5//  Created by Hole Doctor on 14-6-2.6//  Copyrigh T (c) 2014 itcast. All rights reserved. 7//8  9 #import <uikit/uikit.h>10 @interface yyviewcontroller:uiviewcontroller12 @end

The default controller in system storyboard is: Viewcontroller

In this case, if the entire program interface is only built using UITableView, then it is generally necessary to complete the following relatively tedious steps:

(1) Drag a uitableview to the interface

(2) Setting up a data source

(3) Set up Agent

(4) Compliance with agency agreements

The above process is relatively cumbersome, and also need to manually set up data sources, agents, compliance protocol, etc., easy to omit, the following recommended direct use of UITableView Controller.   ii. use of UITableView Controllerto simplify the operation, the following method is introduced. that is, if you only need to display a uitableview on the interface, you can have the host controller directly inherit from the UITableView controller
1//2//  YYViewController.h 3//  UITableView Controller 4//5//  Created by Hole Doctor on 14-6-2.6//  Copyrigh T (c) 2014 itcast. All rights reserved. 7//8  9 #import <uikit/uikit.h>10 @interface yyviewcontroller:uitableviewcontroller12 @end
 Just let the controller inherit uitableview controllers, then delete the previous interface in storyboard, and drag a TableView controller.  Note: You need to associate with the host controller class. The UITableView controller has a TableView property in it, and the view obtained through Self.view in the controller is a tableview. that is Self.view=self.taleview. and it has already implemented his protocols and data sources by default, and no longer needs to be wired.
 1//UITableViewController.h 2//UIKit 3//4//Copyright (c) 2008-2013, Apple Inc. All rights reserved. 5//6 #import <Foundation/Foundation.h> 7 #import <UIKit/UIViewController.h> 8 #import <uikit/ Uitableview.h> 9 #import <uikit/uikitdefines.h>10//Creates a table view with the correct dimensions and auto resizing, setting the DataSource and delegate to self.12//in-viewwillappear:, it reloads the table ' s data if it's empty . Otherwise, it deselects all rows (with or without animation) if clearsselectiononviewwillappear are yes.13//IN-VIEWDIDAP Pear:, it flashes the table ' s scroll indicators.14//implements-setediting:animated:to Toggle the editing state of the table.15 Ns_class_available_ios (2_0) @interface Uitableviewcontroller:uiviewcontroller <uitableviewdelegate, UITABLEVIEWDATASOURCE&GT;17-(ID) Initwithstyle: (Uitableviewstyle) style;19 @property (Nonatomic,retain) UITableView *tableview;21 @property (nonatomic) BOOL ClearsselecTiononviewwillappear Ns_available_ios (3_2); Defaults to YES. If YES, any selection are cleared in viewwillappear:22 @property (nonatomic,retain) Uirefreshcontrol *refreshcontrol ns_ Available_ios (6_0); @end
Right-click to find that the data source and the agent are already connected.  (the controller that inherits from Uiviewcontroller should be killed, and a tableview controller should be dragged back to connect with the master.) )

iOS Development UI article-Direct use of the UITableView Controller

Related Article

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.