Sunday, April 26, 2015

TableViewController With NIB Connection from Library

//
//  MyTableViewController.h
//  MyTableViewApplication
//
//  Created by Krishnan Sriram Rama on 4/26/15.
//  Copyright (c) 2015 Krishnan Sriram Rama. All rights reserved.
//

#import 

@interface MyTableViewController : UITableViewController


@end


//
//  MyTableViewController.m
//  MyTableViewApplication
//
//  Created by Krishnan Sriram Rama on 4/26/15.
//  Copyright (c) 2015 Krishnan Sriram Rama. All rights reserved.
//

#import "MyTableViewController.h"
#import "MyTableViewCellData.h"
#import "MyTableViewCellDataCollection.h"
#import "MyTableViewDetailedWebViewController.h"

@interface MyTableViewController ()
@property (nonatomicstrongNSDictionary *tableData;
@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTableData:[[MyTableViewCellDataCollection sharedManagertableData]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [[self tableDatacount];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50.0f;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell allocinitWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    NSString *currentIndex = [NSString stringWithFormat:@"%ld", ([indexPath row] + 1)];
    MyTableViewCellData *cellData = [[self tableDataobjectForKey:currentIndex];

    [[cell textLabelsetText:[cellData cellData]];
    [[cell detailTextLabelsetText:[cellData subCellData]];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSBundle* bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle]URLForResource:@"MySampleLibraryBundle"
                                                                      withExtension:@"bundle"]];
    MyTableViewDetailedWebViewController *faqController = [[MyTableViewDetailedWebViewController alloc] initWithNibName:@"MyTableViewDetailedWebViewController"
                                                                                                 bundle:bundle];
    [self presentViewController:faqController animated:YES completion:nil];
    
}

@end

No comments: