Learn iOS (4) UIView and its sub-class UITableView with me

Source: Internet
Author: User
UITableView

In the previous section, I talked about UIView. This section describes its important sub-classes: UITableView and UITableViewCell.

UITableView is a subclass of UIScrollView. Therefore, you can scroll through the list composed of UITableViewCell (sub-class of UIView.

UITableView has many things in common with UIScrollView. For in-depth custom views of non-data lists, you can use UIScrollView and deploy the UIView or UIControl subclass in it. However, in this case, UITableView is more advantageous. First, we recommend that you use more advanced abstraction if possible. Second, UITableView automatically implements some subtle functions. One of them is the ability to easily output columns and reuse UITableViewCell units, which can improve performance and reduce memory usage. The other is to fill in the content through feedback of data sources and received delegate Methods

UITableViewController

UITableViewController is a subclass of UIViewController. It can implement some additional functions related to table view loading.If you are usingThe nib file initializes the UITableViewController, And the nib loading mechanism starts from nibThe file is loaded into the archive table view. If not, an unconfigured table view is created.In both cases, you can use the tableView attribute of the UITableViewController class to access the table view.

Generally, a UITableView uses UITableViewController to specify its style. When a UITableViewController is initialized, A UITableView instance is created and assigned to its own View attribute. Both the dataSource and delegate attributes of the UITableView point to the UITableViewController.

@interface ItemsViewController : UITableViewController

 

#import "ItemsViewController.h"@implementation ItemsViewController- (id)init{    self = [super initWithStyle:UITableViewStyleGrouped];    if (self) {    }    return self;}

The call is set to the rootViewControlle of the window as described in the preceding section.

#import "ItemsViewController.h"@implementation HomepwnerAppDelegate- (BOOL)application:(UIApplication *)application    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    ItemsViewController *itemsViewController = [[ItemsViewController alloc] init];

    [[self window] setRootViewController:itemsViewController];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

 

 

It is an empty UITableView created by UITableViewController.

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.