Introduction

Storyboard

Disadvantages of Storyboard

Storyboard

This image shows the flow of control. It shows that the merging of the view is too easy in Storyboard. Storyboard can contain multiple screens at a time.

XIB

Disadvantage of XIB

Step 1

@interface ViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>

{

IBOutlet UITableView *tableview;

NSMutableArray *listoftemple;

IBOutlet UISearchDisplayController *searchBar;

NSMutableArray *listofimages;

}

@property(nonatomic,strong)NSMutableArray *listoftemple;

@property(nonatomic,strong)UITableView *tableview;

@property(nonatomic,strong) IBOutlet UISearchDisplayController *searchBar;

@property(nonatomic,strong) NSMutableArray *listofimages;;

@end

In the first step we drag and drop a table view in a ".h" class file. And we we make the array of images and array of data.

Step 2

- (void)viewDidLoad

{

[super viewDidLoad];

listoftemple=[[NSMutableArray alloc]init];

[listoftemple addObject:@"KALI TEMPLE"] ;

[listoftemple addObject:@"GOLDEN TEMPLE"] ;

[listoftemple addObject:@"KORNAK TEMPLE"] ;

[listoftemple addObject:@"AKSHARDHAM TEMPLE"] ;

[listoftemple addObject:@"MODI MANDIR"];

[listoftemple addObject:@"HINDU TEMPLE"] ;

[listofimages= [[NSMutableArray alloc]init];

[ listofimages addObject: @"download.jpeg"];

[ listofimages addObject:@"download (1).jpeg"];

[ listofimages addObject:@"download (2).jpeg"];

[ listofimages addObject:@"download (4).jpeg"];

[ listofimages addObject:@"download (5).jpeg"];

[ listofimages addObject:@"download (6).jpeg"];

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView

{

return 1;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return [listoftemple count];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

UITableViewCell *cell;

cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];

if (cell == nil)

{

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];

}

cell.imageView.image= [UIImage imageNamed:[NSString stringWithFormat:@"%@",[listofimages objectAtIndex:indexPath.row]]];

cell.textLabel.text= [listoftemple objectAtIndex:indexPath.row];

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}- (NSString *)tableView:(UITableView *)aTableView titleForHeaderInSection:(NSInteger)section

{

return @"LIST OF TEMPLE";

}

- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

return 50;

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

}

@end

Output

Storyboard