TableView im inneren UIViewController

Bin ich möchte ein tableView innerhalb eines UIViewController, denn ich brauche eine Symbolleiste oben in der Ansicht, und ich HIERFÜR nicht verwenden können, den tableViewController. Habe ich eine tableView-Klasse und setzen Sie das, was ich dachte wäre die benötigten Funktionen drin, aber ich muss fehlt etwas, oder haben etwas falsch irgendwo.

.h

import <UIKit/UIKit.h>

@interface TestTV : UITableView
@property(strong,nonatomic)NSArray *arr;

@end

.m

#import "TestTV.h"

@implementation TestTV
@synthesize arr = _arr;

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    //Return the number of sections.
    return 1;
}

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

    _arr = [[NSArray alloc]initWithObjects:@"HEJ",@"FOO", nil];
    return _arr.count;
}

- (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];
    }

    NSString *cellValue = [_arr objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;

    return cell;
}
@end
Schreibe einen Kommentar