I've created a basic application with a UITableView whose cells can display multiple lines of text.

Apologies in advance as my example app is written in Objective-C.

The table view controller (TACTableViewController) is created in the app delegate.

// // TACAppDelegate.m // BasicTable // // Created by Steve Developer on 24/01/18. // Copyright (c) 2018 The App Company. All rights reserved. // #import "TACAppDelegate.h" #import "TACTableViewController.h" @implementation TACAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. // Create table view controller TACTableViewController *tableViewController = [[TACTableViewController alloc] init]; // Place table view controller's table view in the window hierarchy self.window.rootViewController = tableViewController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } ...

The table view controller (TACTableViewController) is a subclass of UITableViewController.

The init and initWithStyle methods in the table view controller are the initialisers and are hopefully self explanatory.

NB 1: For this example app I have hard coded the value returned from method numberOfRowsInSection.

NB 2: In order to customise the behaviour of the cells in the table view, I created a XIB file (TACTableViewCell.xib) and a subclass of UITableViewCell (TACTableViewCell).

NB 3: The viewDidLoad method is overridden only so the cells of the table view can be reused, which in this case is pointless as there are only two cells.

// // TACTableViewController.m // BasicTable // // Created by Steve Developer on 24/01/18. // Copyright (c) 2018 The App Company. All rights reserved. // #import "TACTableViewController.h" #import "TACTableViewCell.h" @implementation TACTableViewController - (instancetype)init { // Call the superclass's designated initializer self = [super initWithStyle:UITableViewStyleGrouped]; return self; } - (instancetype)initWithStyle:(UITableViewStyle)style { self = [self init]; return self; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 2; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // Get a new or recycled cell TACTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TACTableViewCell" forIndexPath:indexPath]; // You would normally retrieve data using your model class at this point NSString *string = @"The quick brown fox jumped over the lazy dog."; cell.label.text = string; return cell; } // Required to override this method in order to recycle table view cells - (void)viewDidLoad { [super viewDidLoad]; // Load the NIB file UINib *nib = [UINib nibWithNibName:@"TACTableViewCell" bundle:nil]; // Register this NIB, which contains the cell [self.tableView registerNib:nib forCellReuseIdentifier:@"TACTableViewCell"]; } @end

TACTableViewCell is a subclass of UITableViewCell and its header and implementation files are almost empty apart from the IBOutlet, named label, in the header. This outlet (will) point to the UILabel in TACTableViewCell.xib.

The header file:

// // TACTableViewCell.h // BasicTable // // Created by Steve Developer on 24/01/18. // Copyright (c) 2018 The App Company. All rights reserved. // #import <Foundation/Foundation.h> @interface TACTableViewCell : UITableViewCell @property (weak, nonatomic) IBOutlet UILabel *label; @end

The implemenation file:

// // TACTableViewCell.m // BasicTable // // Created by Steve Developer on 24/01/18. // Copyright (c) 2018 The App Company. All rights reserved. // #import "TACTableViewCell.h" @implementation TACTableViewCell @end

To create the TACTableViewCell.xib file do the following:

Add a new empty User Interface file to your project, name it TACTableViewCell.xib. Open the XIB file and add a Table View Cell to the canvas. Add a Label to the Table View Cell (I stretched the label to almost the width of the Table View Cell).

Specify the spacing to the label's nearest neighbour by adding four constraints.

The newly added constraints are displayed in the dock to the left of the canvas.

Change the Lines attribute for the Label from 1 to 0.

Connect the IBOutlet, named label, in the TACTableViewCell class with the Label in Interface Builder, by clicking the circle in the margin next to the line shown below and dragging to the Label in the canvas.

At this point the app should build and run successfully and display something similar to that below.