How do I make my UITableView Scroll? - iphone

In the following code, I push a new UITableView when I click on a button. The TableView has 25 rows. I can see the first 9 row and the 10th row got cut off. I can't scroll down to view the rest of the rows. How do I make the TableView scrollable? Thank you.
- (IBAction)showListPicker:(id)sender {
ListPicker *lp = [[ListPicker alloc] initWithStyle:UITableViewStyleGrouped];
[self setTitle:#"Home"];
[[self navigationController] pushViewController:lp animated:YES];
[lp release];
}
The following is the declaration for ListPicker
#import <Foundation/Foundation.h>
#interface ListPicker : UITableViewController
{}
#end
The following is the implementation for ListPIcker
#import "ListPicker.h"
#import "GameStore.h"
#import "List.h"
#import "HomeViewController.h"
#implementation ListPicker
- (id)init
{
return [super initWithStyle:UITableViewStyleGrouped];
}
-(id)initWithStyle:(UITableViewStyle)style{
return [self init];
}
-(void)dealloc{
[super dealloc];
}
-(void)viewDidLoad{
[self setTitle:#"Select List"];
[[self navigationController] setNavigationBarHidden:NO];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [[[GameStore defaultStore] allLists] count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"UITableViewCell"];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:#"UITableViewCell"] autorelease];
}
NSArray *allList = [[GameStore defaultStore] allLists];
List *mylist = [allList objectAtIndex:[indexPath row]];
NSString *listTitle = [mylist label];
[[cell textLabel] setText:listTitle];
[cell setAccessoryType:UITableViewCellAccessoryNone];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
List *list = [[[GameStore defaultStore] allLists] objectAtIndex:[indexPath row]];
[[GameStore defaultStore] setSelectedList:list];
HomeViewController *hv = [[HomeViewController alloc] init];
[[self navigationController] popViewControllerAnimated:YES];
}
#end

Try to add:
yourTable.scrollEnabled = YES;
Also, when you create your table programmatically, make sure it is "long enough", i.e.,
CGRect cgRct = CGRectMake(0, 0, 320, 600);
yourTable = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStyleGrouped];

Instead of YES, write true as it accepts only bool values.
yourTable.scrollEnabled = true;

Two common ways to change the boolean state of scrolling in a UITableView:
1) It can be enabled either in the attributes inspector of the UITableView via Storyboard.
2) Or programmatically inside your viewDidLoad() via ViewController.
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
#IBOutlet var yourTable: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// assign delegate and datasource
yourTable.delegate = self
yourTable.dataSource = self
//enable UITableView scrolling in Swift 3 and Swift 4.
yourTable.isScrollEnabled = true
}
}

Related

How to set the subclass of a TableView that was created programmatically? (no storyboards)

I am using a custom framework and I need to set the subclass of my 'TableView' and 'TableViewCell' to the custom framework. I would normally do this easily with the identity inspector but since I created everything programmatically, I do not know how to do it. I am also not using storyboards. Any tips?
---edit----
TableViewController.h
#import <UIKit/UIKit.h>
#import "Tasks.h"
#import "Properties2ViewController.h"
#import "PKRevealController.h"
#import "FMMoveTableView.h"
#import "FMMoveTableViewCell.h"
#import "DetailViewController.h"
#interface ToDoTableViewController : UITableViewController <Properties2ViewControllerDelegate, UITableViewDelegate, FMMoveTableViewDataSource>
#property (strong, nonatomic) NSMutableArray *taskArray;
-(IBAction)addCell:(id)sender;
#end
TableViewController.m
#import "ToDoTableViewController.h"
#implementation ToDoTableViewController
#synthesize taskArray;
- (id)init {
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
UINavigationItem *i = [self navigationItem];
[i setTitle:#"Task List"];
[[i title] uppercaseString];
UIBarButtonItem *bbi = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addCell:)];
[[self navigationItem] setRightBarButtonItem:bbi];
[self.tableView setSeparatorColor:[UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f]];
[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundColor:[UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f]];
}
return self;
}
- (id) initWithStyle:(UITableViewStyle)style{
return [self init];
}
-(void) viewDidLoad{
FMMoveTableView *mtc = [[FMMoveTableView alloc]init];
[mtc setDataSource:self];
[self.tableView setDelegate:self];
taskArray = [[NSMutableArray alloc] init];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"UITableViewCell"];
if (!cell)
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:#"UITableViewCell"];
NSString *detailText = [NSString stringWithFormat:#"%.0f", [[taskArray objectAtIndex:[indexPath row]] timeInterval]];
[[cell textLabel] setText:[[taskArray objectAtIndex:[indexPath row]] taskName]];
cell.textLabel.text = [[[taskArray objectAtIndex:[indexPath row]] taskName] uppercaseString];
[[cell textLabel] setFont:[UIFont fontWithName:#"AvenirNext-DemiBold" size:15]];
[cell setBackgroundColor:[UIColor colorWithRed:236.0/255 green:240.0/255 blue:241.0/255 alpha:1.0f]];
cell.textLabel.textColor = [UIColor colorWithRed:26.0/255 green:188.0/255 blue:156.0/255 alpha:1.0f];
[[cell detailTextLabel] setText:detailText];
[[cell detailTextLabel] setFont:[UIFont fontWithName:#"Avenir-Black" size:16]];
return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [taskArray count];
}
-(IBAction)addCell:(id)sender{
Properties2ViewController *pvc = [[Properties2ViewController alloc]init];
[pvc setDelegate:self];
[self presentViewController:pvc animated:YES completion:NULL];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[self tableView] reloadData];
}
-(void)properties2ViewControllerDidEnterPropertiesSuccesfully:(Tasks *)t{
if (![[t taskName] isEqual: #""]) {
[taskArray addObject:t];
}
[self.tableView reloadData];
}
-(void)moveTableView:(FMMoveTableView *)tableView moveRowFromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath{
[tableView moveRowAtIndexPath:fromIndexPath toIndexPath:toIndexPath];
[tableView reloadData];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
Tasks *task = [taskArray objectAtIndex:[indexPath row]];
DetailViewController *dvc = [[DetailViewController alloc]init];
[dvc setTestTask:task];
[[self navigationController] pushViewController:dvc animated:YES];
// PKRevealController *pkrc = [[PKRevealController alloc]initWithFrontViewController:self rightViewController:dvc options:nil];
//[pkrc showViewController:dvc animated:YES completion:NULL];
}
-(void)loadView{
[super loadView];
}
#end
If you are instantiating the UITableView yourself, just instantiate the library class instead. For example, if you said this:
UITableView *tableView = [[UITableView alloc] initWithFrame:frame
style: UITableViewStylePlain];
then do this instead:
LibraryTableView *tableView = [[LibraryTableView alloc] initWithFrame:frame
style:UITableViewStylePlain];
If LibraryTableView provides some other, more specialized initWith… method, you may need to use that instead.
If you're storing a reference to the table view in a property or instance variable, you may also want to change the type of that property or instance variable from UITableView * to LibraryTableView *.
UPDATE
I believe if you're using a UITableViewController, you can create your own table view and assign it to the controller's tableView property:
UITableViewController *tvc = ...;
tvc.tableView = [[LibraryTableView alloc] initWithFrame:frame
style:UITableViewStylePlain];
UPDATE 2
In your viewDidLoad, you're creating an FMMoveTableView, but you're not storing it in the view controller's tableView property. You must store it in the view controller's tableView property, and when you do, the view controller will automatically set the table view's dataSource and delegate to self.
-(void) viewDidLoad{
self.tableView = [[FMMoveTableView alloc] init];
taskArray = [[NSMutableArray alloc] init];
}
In your tableView:cellForRowAtIndexPath:, you need to instantiate an FMMoveTableViewCell, not a UITableViewCell. You send the alloc message to the class you want to instantiate:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell"];
if (!cell) {
cell = [[FMMoveTableViewCell alloc]
initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:#"Cell"];
}
// etc.
If you have your own custom subclass of FMMoveTableViewCell, instantiate that instead.
I have created custom TableViewCells before, you can create a custom class just like you would for viewControllers (File > New > File). When choosing which object to subclass, choose UITableViewCell.
Unfortunately, Xcode will not give you the option to include a .xib file, so you'll have to create one of those too: File > New > File, but this time on the left side of the window that pops up, select 'User Interface' instead of 'Cocoa Touch'. Choose the 'Empty' icon at this screen.
You will be asked whether the device family is iPhone or iPad. Since you are making a table view cell not a viewController, it doesn't matter which you pick.
When you create this object you will be presented with a blank canvas. Drag a 'Table View Cell' from the object library to the canvas and you're set to start creating!
It is of note that where you'd normally create outlets, you should create properties for TableViewCells. This is because other objects are going to be interacting with the TableViewCell, not just the TableViewCell's implementation file.
Here is what a header file for a custom TableViewCell might look like:
#interface MyCustomCell : UITableViewCell
#property (weak, nonatomic) IBOutlet UIImageView *icon;
#property (weak, nonatomic) IBOutlet UILabel *label;
#property (weak, nonatomic) IBOutlet UILabel *number;
#end
My implementation file was empty.
However, that's not all. There is also some work to be done in the TableViewController that will utilize this cell. Be sure to import your TableViewCell's header file.
First, the cell has to be registered in the viewDidLoad method
// Resiter the Nib
UINib *nib = [UINib nibWithNibName:#"MyCustomCell" bundle:nil];
[[self tableView] registerNib:nib forCellReuseIdentifier:#"MyCustomCell"];
And then when the TableViewController determines how to draw the cells:
- (UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MyCustomCell"]
// Then here you can set the properties of each cell
[[cell label] setText:#"Some text here"];
[[cell number] setText:[NSString stringWithFormat:#"%d", 5]];
[[cell icon] setImage:[UIImage imageNamed:#"myImage]];
}
I hope this is helpful!

UITableView using ECSlidingViewController not Populating

I'm trying to populate the menu in ECSlidingViewController(a UITableVIEW) using the code below, but when I run the app the menu, or uitableview, is blank and not populated with the 3 MenuItems; Important, Invitation, and Agenda. I suspect the problem lies within didSelectRowAtIndexPath, but I'm not sure. Any help with this would be much appreciated. Thank you.
#import "MenuViewController.h"
#interface MenuViewController ()
#property (nonatomic, strong) NSArray *menuItems;
#end
#implementation MenuViewController
#synthesize menuItems;
- (void)awakeFromNib
{
self.menuItems = [NSArray arrayWithObjects:#"Important", #"Invitation", #"Agenda", nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self.slidingViewController setAnchorRightRevealAmount:280.0f];
self.slidingViewController.underLeftWidthLayout = ECFullWidth;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
return self.menuItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = #"MenuItemCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = [self.menuItems objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = [NSString stringWithFormat:#"%#", [self.menuItems objectAtIndex:indexPath.row]];
UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
CGRect frame = self.slidingViewController.topViewController.view.frame;
self.slidingViewController.topViewController = newTopViewController;
self.slidingViewController.topViewController.view.frame = frame;
[self.slidingViewController resetTopView];
}];
}
1) Be sure to connect datasource and delegate outlets in IB, and
2) Is MenuViewController a subclass of UITableViewController? If not, then I think you're going to need to load the table data yourself someplace. Try this:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData]; // need to have an outlet named this
}
If you don't have an outlet setup called tableView, pointing to the table view, create one in IB.
I suspect that your menuItems array is empty. Try populating it in viewDidLoad.
You may want to take a look at this for a discussion of awakeFromNib, viewDidLoad, initWithNibName.

How to link a UITableViewController to multiple ViewControllers and how to call them

I'm trying to link cells from an UITableViewController to UIViewController, but each cell has to call a different UIViewController (so I imagine that I'll have to create one link to each view controller) and I don't know how to link them through storyboard.
This is what I have until now:
MainView.h
#interface MainView : UITableViewController <UITableViewDelegate, UITableViewDataSource>
{
NSArray *tableData;
}
#property (nonatomic, retain) NSArray *tableData;
#end
MainView.m
- (void)viewDidLoad
{
tableData = [[NSArray alloc] initWithObjects:#"1", #"2", #"3", #"4", nil];
[super viewDidLoad];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:#"MyCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MyCell"];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIViewController *anotherVC = nil;
if (indexPath.section == 0) //here I've also tried to use switch, case 0, etc
{
if (indexPath.row == 0)
{
anotherVC = [[ViewForFirstRow alloc] init];
}
NSLog(#"anotherVC %#", anotherVC); // shows that anotherVC = ViewForFirstRow
[anotherVC setModalPresentationStyle:UIModalPresentationFormSheet];
[anotherVC setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self.navigationController pushViewController:anotherVC animated:YES];
}
}
#end
So, when first row is selected and I didn't link UITableViewController to UIViewController (ViewForFirstRow), it shows a black screen.
If I link UITableViewController to ViewForFirstRow, it opens the view but without the effect I used in code [self.navigationController pushViewController:anotherVC animated:YES];, so it appears that it called the view due to the link and not because of the code [self.navigationController pushViewController:anotherVC animated:YES];
How can I call the view by code properly and what kind of link should I use in storyboard for that? Also, how can I link the UITableViewController to multiples UIViewController (ViewForFirstRow, ViewForSecondRow, ViewForThirdRow, etc).
Thanks!
First, you can't hook up segues from cell (in a dynamic table view) in the storyboard, you have to do it in code. The code should look like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0) {
UIViewController *anotherVC = [self.storyboard instantiateViewControllerWithIdentifier:#"anotherVC"];
[self.navigationController pushViewController:anotherVC animated:YES];
}else if (indexPath.row == 1) {
UIViewController *someOtherVC = [self.storyboard instantiateViewControllerWithIdentifier:#"someOtherVC"];
[self.navigationController pushViewController:someOtherVC animated:YES];
}
}
You shouldn't be doing anything with indexPath.section since your table view only has one section.
In storyboard presenting another viewcontroller in modally manner then use this:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
Synergy *objSynergy = (Synergy *)[mainStoryboard instantiateViewControllerWithIdentifier:#"Synergy"];
[self presentModalViewController:objSynergy animated:YES];
Synergy is my controller name You can put here your controller name that you want to present.
Make changes with your requirement. And for different viewcontroller open from different row
Use this:
if (indexPath.section==0)
{
if (indexPath.row ==0)
{
}
}

Making rounded corners for the first and last cell of UITableView

I would like to make rounded corners for the first and last cell of UITableView. I have seen from this postCustom Rounded corners that you can use custom cells in a xib file, set their unique identifiers like: #"beginCell", #"middleCell", #"endCell". I do not want to use custom cells. Is there any other way to do this?
For example:
if (cell.count == 0 or cell.count == last)
{
cell.layer.cornerRadius = 10;
}
Something like this. But there is no property called count. Is there any other property?
EDITED:
ViewController.m
#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "SecondViewController.h"
#interface ViewController ()
#end
#implementation ViewController
#synthesize tableItems,images;
- (void)viewDidLoad
{
[super viewDidLoad];
tableItems = [[NSArray alloc] initWithObjects:#"Item1",#"Item2",#"Item3",nil];
images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:#"clock.png"],[UIImage imageNamed:#"eye.png"],[UIImage imageNamed:#"target.png"],nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Required Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return tableItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//Step 1:Check whether if we can reuse a cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell"];
//If there are no new cells to reuse,create a new one
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:#"cell"];
UIView *v = [[UIView alloc] init];
v.backgroundColor = [UIColor redColor];
cell.selectedBackgroundView = v;
//changing the radius of the corners
//cell.layer.cornerRadius = 10;
}
//Set the image in the row
cell.imageView.image = [images objectAtIndex:indexPath.row];
//Step 3: Set the cell text content
cell.textLabel.text = [tableItems objectAtIndex:indexPath.row];
//Step 4: Return the row
return cell;
}
#pragma mark - Optional Methods
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.backgroundColor = [ UIColor greenColor];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
NSString *selectedRow = [tableItems objectAtIndex:indexPath.row];
secondViewController.selectedRow = selectedRow;
//[self.navigationController pushViewController:secondViewController animated:YES];
[self presentViewController:secondViewController animated:YES completion:nil];
[secondViewController printRowNumber:indexPath.row];
}
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
self = [super initWithFrame:frame style:style];
return self;
}
#end
Just change your UITableView initialization style to Grouped like that:
yourTableViewController = [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
This will make your first cell rounded from top and last cell rounded from bottom.
EDIT in case of not using UITableViewController initializer:
#interface YourViewController
#property (strong, nonatomic) UITableView *tableView;
#end
#implementation YourViewController
- (id)initWithFrame:(CGRect)frame
{
if (self = [super init])
{
...
tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
...
[self.view addSubview:tableView];
}
return self;
}
#end
Assuming you're putting this code in tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath, you can do it like this:
if (indexPath.row == 0 || indexPath.row == ([indexPath length]-1))
{
cell.layer.cornerRadius = 10;
}

UITableView in UINavigationController causes EXC_BAD_ACCESS

below test code causes EXC_BAD_ACCESS when it's scrolled many time.
would somebody like to tell me the problem?
-myview.h---------------------------------------------------
#interface MyView : UINavigationController < UITableViewDataSource, UITableViewDelegate, UINavigationBarDelegate >
{
UITableView* mTableView;
NSMutableArray* data;
}
-myview.m---------------------------------------------------
#implementation MyView
- (void)viewDidLoad
{
[super viewDidLoad];
int th = self.navigationBar.frame.size.height;
int w = self.view.frame.size.width;
int h = self.view.frame.size.height;
mTableView = [[[UITableView alloc] initWithFrame:
CGRectMake(0.0f, th, w, h - th) style:UITableViewStylePlain] retain];
mTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
mTableView.dataSource = self;
mTableView.delegate = self;
[mTableView setRowHeight:55];
[self.view addSubview:mTableView];
data = [[[NSMutableArray alloc] init] retain];
for (int i = 0; i < 150; i++)
{
[data addObject:[NSDictionary
dictionaryWithObjects:[NSArray arrayWithObjects:#"good", [UIColor blackColor], nil]
forKeys:[NSArray arrayWithObjects:#"name", #"color", nil]]];
}
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 150;
}
- (UITableViewCell *)tableViewCellWithReuseIdentifier:(NSString *)identifier
{
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
cell.textLabel.text = #"goooood";
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [self tableViewCellWithReuseIdentifier:CellIdentifier];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (void)dealloc
{
[super dealloc];
}
- (BOOL)canBecomeFirstResponder
{
return YES;
}
#end
You should have a view controller that contains your table view (it could even be a subclass of UITableViewController). I don't believe that UINavigationController is mean't to be subclassed as you have. If you want a navigation controller you should create an instance of CustomTableViewController, containing your tableview, and then use the initWithRootViewController: method of UINavigationController:
CustomTableViewController * ctvc = [[CustomTableViewController alloc] init];
UINavigationController * navigationController = [[UINavigationController alloc] initWithRootViewController:ctvc];
[ctvc release];
// Superview is where you want this added
// probably your window in app did finish launching
[superview addSubview:navigationController.view];
[navigationController release];