GroupedTableViewController.h
#import <UIKit/UIKit.h>
@interface GroupedTableViewController: UIViewController<UITableViewDelegate, UITableViewDataSource>
{
NSArray *tableData,*tableData1;
IBOutlet UITableView *tableView1;
}
@end
GroupedTableViewController.m
#import "GroupedTableViewController.h"
@interface GroupedTableViewControllerViewController ()
@end
@implementation GroupedTableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//self.navigationItem.title = @"Title";
// self.navigationItem.leftBarButtonItem = self.editButtonItem;
tableData = [[NSArray alloc]initWithObjects: @"Cab Operators ",@"Package Tours",@"Group Vehicles",@"Rate Card",nil];
tableData1 = [[NSArray alloc]initWithObjects: @"Package Tours",@"Cab Operators",@"Group Vehicles",@"Rate Card",nil];
tableView1.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight;
//NSLog(@"%d",tableData.count);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#pragma mark - Table view data source
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50.0f;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return tableData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier; //= @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSUInteger row = [indexPath row];
if (indexPath.section==0)
{
cell.textLabel.font=[UIFont systemFontOfSize:14];
cell.textLabel.textAlignment=NSTextAlignmentLeft;
//[cell setSelectionStyle:UITableViewCellEditingStyleNone];
cell.textLabel.text = [tableData objectAtIndex:row];
}
else
{
/* UILabel *description=[[UILabel alloc]initWithFrame:CGRectMake(100, 0, 210,44 )];
description.text=[NSString stringWithFormat: @"%@",[tableData1 objectAtIndex:indexPath.row]];
[description setFont:[UIFont systemFontOfSize:14]];
description.textColor=[UIColor blackColor];
description.backgroundColor=[UIColor clearColor];
//description.textColor=[UIColor colorWithRed:131.0f/255.0f green:15.0f/255.0f blue:19.0f/255.0f alpha:1];
description.numberOfLines=3;
[cell.contentView addSubview:description];*/
cell.textLabel.font=[UIFont systemFontOfSize:14];
cell.textLabel.textAlignment=NSTextAlignmentLeft;
//[cell setSelectionStyle:UITableViewCellEditingStyleNone];
cell.textLabel.text = [tableData1 objectAtIndex:row];
}
tableView.backgroundColor=[UIColor clearColor];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Tested");
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
No comments:
Post a Comment