summaryrefslogtreecommitdiff
path: root/SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m')
-rw-r--r--SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m130
1 files changed, 130 insertions, 0 deletions
diff --git a/SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m b/SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m
new file mode 100644
index 0000000..0eae055
--- /dev/null
+++ b/SplitViewXIBFonts/SplitViewXIBFonts/MasterViewController.m
@@ -0,0 +1,130 @@
+//
+// MasterViewController.m
+// SplitViewXIBFonts
+//
+// Created by mo khan on 2013-05-28.
+// Copyright (c) 2013 mo khan. All rights reserved.
+//
+
+#import "MasterViewController.h"
+
+#import "DetailViewController.h"
+
+@implementation MasterViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self) {
+ self.title = @"Fonts";
+ self.clearsSelectionOnViewWillAppear = NO;
+ self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
+ }
+ return self;
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ NSArray * arrFamilyNames = [UIFont familyNames];
+ NSMutableArray * arrMutableFontNames = [[NSMutableArray alloc] init];
+ self.arrFontNamesIndex = [[NSMutableArray alloc] init];
+
+ for (NSString * familyName in arrFamilyNames)
+ {
+ [arrMutableFontNames addObjectsFromArray:[UIFont fontNamesForFamilyName:familyName]];
+ }
+
+ [arrMutableFontNames sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
+ NSLog(@"%@", arrMutableFontNames);
+
+ // Do any additional setup after loading the view, typically from a nib.
+ self.navigationItem.leftBarButtonItem = self.editButtonItem;
+
+ UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)];
+ self.navigationItem.rightBarButtonItem = addButton;
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+- (void)insertNewObject:(id)sender
+{
+// if (!_objects) {
+// _objects = [[NSMutableArray alloc] init];
+// }
+// [_objects insertObject:[NSDate date] atIndex:0];
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+ [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
+}
+
+#pragma mark - Table View
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+// return _objects.count;
+}
+
+// Customize the appearance of table view cells.
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
+ }
+
+
+// NSDate *object = _objects[indexPath.row];
+// cell.textLabel.text = [object description];
+ return cell;
+}
+
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // Return NO if you do not want the specified item to be editable.
+ return YES;
+}
+
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ if (editingStyle == UITableViewCellEditingStyleDelete) {
+// [_objects removeObjectAtIndex:indexPath.row];
+ [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
+ } else if (editingStyle == UITableViewCellEditingStyleInsert) {
+ // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
+ }
+}
+
+/*
+// Override to support rearranging the table view.
+- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
+{
+}
+*/
+
+/*
+// Override to support conditional rearranging of the table view.
+- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // Return NO if you do not want the item to be re-orderable.
+ return YES;
+}
+*/
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+// NSDate *object = _objects[indexPath.row];
+// self.detailViewController.detailItem = object;
+}
+
+@end