// ViewController.m
// IBcells
#import "ViewController.h"
#import "BMSetting.h"
@interface ViewController ()
@end
@implementation ViewController {
NSArray *settingArray;
}
//-(id)init {
// self = [super init];
// if (self) {
// //self.tableView = [[UITableView alloc] initWithFrame:self.bounds];
// //self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// self.tableView.dataSource = self;
// self.tableView.delegate = self;
// //self.tableView.scrollEnabled = NO;
// //self.tableView.layer.cornerRadius = PanelCornerRadius;
// //[self addSubview:self.tableView];
// }
// return self;
//}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource = self;
self.tableView.delegate = self;
// Create settings array
BMSetting *setting1 = [BMSetting new];
setting1.name = @"Live Call Confirmation";
setting1.detail = @"An alert pops up and asks if you are sure that you would like to make to the studio";
setting1.setOn = @"There will be a pop up that confirms that you really do wish to make the call";
setting1.setOff = @"The call will go through right away";
BMSetting *setting2 = [BMSetting new];
setting2.name = @"Play On Launch";
setting2.detail = @"The option to have Radio automatically start playing when the application launches";
setting1.setOn = @"The radio will start playing when the application launches";
setting1.setOff = @"The play button will need to have to be clicked for the audio to start playing";
BMSetting *setting3 = [BMSetting new];
setting3.name = @"Allow Landscape Orientation";
setting3.detail = @"Enables the applications to be used in all orientations";
setting1.setOn = @"The application could be used when the device is sideways";
setting1.setOff = @"The application will only work in portrait style";
settingArray = [NSArray arrayWithObjects:setting1, setting2, setting3, nil];
// Assign our own backgroud for the view
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"common_bg"]];
self.tableView.backgroundColor = [UIColor clearColor];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return settingArray.count;
}
- (UIImage *)cellBackgroundForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger rowCount = [self tableView:[self tableView] numberOfRowsInSection:0];
NSInteger rowIndex = indexPath.row;
UIImage *background = nil;
if (rowIndex == 0) {
background = [UIImage imageNamed:@"cell_top.png"];
} else if (rowIndex == rowCount - 1) {
background = [UIImage imageNamed:@"cell_bottom.png"];
} else {
background = [UIImage imageNamed:@"cell_middle.png"];
}
return background;
}
- (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];
}
// Display recipe in the table cell
BMSetting *setting = [settingArray objectAtIndex:indexPath.row];
UILabel *settingNameLabel = (UILabel *)[cell viewWithTag:101];
settingNameLabel.text = setting.name;
// Assign our own background image for the cell
UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
cellBackgroundView.image = background;
cell.backgroundView = cellBackgroundView;
return cell;
}
@end
// BMSetting.h
// IBcells
#import <Foundation/Foundation.h>
@interface BMSetting : NSObject
@property (nonatomic, strong) NSString *name; // Name of setting
@property (nonatomic, strong) NSString *detail; // Setting details
@property (nonatomic, strong) NSString *setOn; // Setting is set to On
@property (nonatomic, strong) NSString *setOff; // Setting is set to Off
//@property (nonatomic, strong) IBOutlet UISwitch *settingSwitch;
//@property (nonatomic, strong) NSString *imageFile; // image filename of recipe
@end
Comments