Introduction
In this article I will create an Empty view application. Here I use a Grouped table from an outlet and set four labels and an image view on it. Here we add a storyboard from a resource.
To understand it we use the following procedure.
Step 1
Initially we add a storyboardViewController Class of the UITableViewController type.
To add a UITableViewController Objective-C Class we use the following:
Select the App delegate class and right-click on it to add a new file.
Select Objective-C Class and Click on Next.
Now Select UITableViewController Class without Xib and click on Next.
Now Click on Create to import it to the project.
Step 2
Now we add a storyboard Class. To add a storyboard we use the following:
Select Storyboard class and right-click on it to add a new file.
Select User Interface Storyboard and click on Next.
Now select device family and click on Next.
Click on Create.
Step 3
Here we write the code.
storyboardViewController.h
#import <UIKit/UIKit.h>
@interface storyboardViewController : UITableViewController
@property (strong, nonatomic) IBOutlet UILabel *NameLabel;
@property (strong, nonatomic) IBOutlet UILabel *DesignationLabel;
@property (strong, nonatomic) IBOutlet UIImageView *ImageView;
@end
storyboardViewController.m
#import "storyboardViewController.h"
@interface storyboardViewController ()
@end
@implementation storyboardViewController
@synthesize NameLabel;
@synthesize DesignationLabel;
@synthesize ImageView;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.NameLabel.text = @"Sachin";
self.DesignationLabel.text = @"iPhone Developer";
self.ImageView.image = [UIImage imageNamed: @"image1.jpeg"];
}
#pragma mark - Table view data source
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
}
@end
Storyboary.storyboard
Step 4
Select table style -> Grouped
Step 5
Select Table View Section and Set Header Footer
Step 6
Now we click on Storyboard TableViewController Class and Check all Connections and perform the linking.
Step 7
Now run the application and see the output.
Output
Before Scroll down
After scroll Down.