I have table in which i would like to tap on the cell and it takes me to another table.
I got this error while running in Xcode 4.3.2 :
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RanchForecastTouchAppDelegate class]));
Thread 1: Signal SIGABRT
I saw alot of answer related this error in this forum but it didn't work, it's the reason that I asked question again.
My code is:
CreateViewController.h
#import <UIKit/UIKit.h>
#interface CreateViewController : UIViewController <
UITableViewDataSource, UITableViewDelegate>
{
NSArray *tableData;
}
#property (nonatomic, retain) NSArray *tableData;
#end
CreateViewController.m
#import "CreateViewController.h"
#implementation CreateViewController
#synthesize tableData;
#pragma mark - View lifecycle
- (void)viewDidLoad
{
tableData = [[NSArray alloc] initWithObjects:#"Johan", #"Paul",#"George",#"Ringo", nil];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
#pragma mark - TableView Data Source methods
- (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;
}
#end
Error message on console:
[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x68ab4d0
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x68ab4d0'
Edit:
#import "RanchForecastTouchViewController.h"
#interface RanchForecastTouchViewController ()
#end
#implementation RanchForecastTouchViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#end
RanchForecastTouchViewController.h
#import <UIKit/UIKit.h>
#interface RanchForecastTouchViewController : UIViewController
#end
check your user interface connection, It would be for some wrong connections!
you added semicolons at the end of the line
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{ ...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{....
}
just remove them
Related
I'm trying to create a simple TableView in my current project.
but I got this error after connected datasource in IB and run iOS simulator.
2013-03-22 14:58:32.372 M[1875:c07] -[ViewController tableView:numberOfRowsInSection:]:
unrecognized selector sent to instance 0x88191f0
2013-03-22 14:58:32.374 M[1875:c07] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[ViewController tableView:numberOfRowsInSection:]:
unrecognized selector sent to instance 0x88191f0'
,but when I create a simple TableView in an empty project with the same code it's working.
Here is my code
"MCEventActivityViewController.h"
#import <UIKit/UIKit.h>
#interface MCEventActivityViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
#end
"MCEventActivityViewController.m"
#import "MCEventActivityViewController.h"
#interface MCEventActivityViewController ()
#end
#implementation MCEventActivityViewController
{
NSArray *tableData;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
tableData = [NSArray arrayWithObjects:#"1", #"2", #"3", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = #"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
#end
Could anyone help me figure out why this error came out?
The screenshots are here.
Edited:
Make sure,
1.TableView is connected with FileOwner in XIB.
2.#interface Controller : UIViewController UITableViewDelegate,UITableViewDataSource included.
3.Delegate & DataSource both connected with FileOwner.
4.numberOfSections return 1.
5.numberOfRowsInSection returns [required].
6.cellForRowAtIndexPath
{ data goes here...
}
Edited:
Create,
#property (nonatomic,strong) IBOutlet UITabelView * tableView;
and connect this Outlet in Xib with Fileowner
Add numberOfSectionsInTableView method to your code
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
Add NSArray *tableData; to MCEventActivityViewController.h
and set its #property and #synthesize properly.
and write
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.tableData = [[NSArray alloc] initWithObjects:#"1", #"2", #"3", nil];
}
You should link the (dataSource and delegate) from Outlets to the view controller not to view ! like these pictures :
I'm trying to code an app in Xcode 4, with storyboarding. It's a master detail application, and it all worked fine, with the table and the detail view. But in my detail view, I would like to have a static table to display the data. In a grouped table style way, with the "key" on the left and "value" on the right, if that's a way to put it... So, it's all working fine until I put a table into my UIView. Apparently you have to put it in a UITableView for it to work, so I deleted the UIView that Xcode made for me and put in a UITableView in its place. I set it up EXACTLY the same (I think) with the identifier, title etc... and then connect the table cells up with outlets and what not. But now when I enter the view, I just get an empty table (well, not empty, just all the rows say "Detail" in rather than the actual data I want). I don't see why! D: I even changed DetailViewController.h to say "UITableViewController" as well! No avail... :( Could someone please enlighten me as to what I'm doing wrong! I bet it's really simple... :L Here's my code
MasterViewController.h
#import <UIKit/UIKit.h>
#class DetailViewController;
#interface MasterViewController : UITableViewController
#property (strong, nonatomic) DetailViewController *detailViewController;
#property (strong) NSMutableArray *verbs;
#end
MasterViewController.m
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "VerbData.h"
#interface MasterViewController () {
NSMutableArray *_objects;
}
#end
#implementation MasterViewController
#synthesize verbs = _verbs;
- (void)awakeFromNib
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
[super awakeFromNib];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.detailViewController = (DetailViewController *) [[self.splitViewController.viewControllers lastObject] topViewController];
self.title = #"Verbs";
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (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 _verbs.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"VerbCell"];
VerbData *verb = [self.verbs objectAtIndex:indexPath.row];
cell.textLabel.text = verb.infinitive;
cell.detailTextLabel.text = verb.english;
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
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
VerbData *object = [self.verbs objectAtIndex:indexPath.row];
self.detailViewController.detailItem = object;
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
VerbData *object = [self.verbs objectAtIndex:indexPath.row];
[[segue destinationViewController] setDetailItem:object];
}
}
#end
DetailViewController.h
#import <UIKit/UIKit.h>
#import "VerbData.h"
#interface DetailViewController : UITableViewController <UISplitViewControllerDelegate>
#property (strong, nonatomic) VerbData *detailItem;
#property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;
#property (weak, nonatomic) IBOutlet UILabel *jeOutlet;
#property (weak, nonatomic) IBOutlet UILabel *tuOutlet;
#property (weak, nonatomic) IBOutlet UILabel *ilOutlet;
#property (weak, nonatomic) IBOutlet UILabel *nousOutlet;
#property (weak, nonatomic) IBOutlet UILabel *vousOutlet;
#property (weak, nonatomic) IBOutlet UILabel *ilsOutlet;
#end
DetailViewController.m
#import "DetailViewController.h"
#interface DetailViewController ()
#property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
#end
#implementation DetailViewController
#pragma mark - Managing the detail item
#synthesize detailItem = _detailItem;
#synthesize jeOutlet = _jeOutlet;
#synthesize tuOutlet = _tuOutlet;
#synthesize ilOutlet = _ilOutlet;
#synthesize nousOutlet = _nousOutlet;
#synthesize vousOutlet = _vousOutlet;
#synthesize ilsOutlet = _ilsOutlet;
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem) {
self.detailDescriptionLabel.text = self.detailItem.english;
self.jeOutlet.text = self.detailItem.je;
self.tuOutlet.text = self.detailItem.tu;
self.ilOutlet.text = self.detailItem.il;
self.nousOutlet.text = self.detailItem.nous;
self.vousOutlet.text = self.detailItem.vous;
self.ilsOutlet.text = self.detailItem.ils;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = self.detailItem.infinitive;
[self configureView];
}
- (void)viewDidUnload
{
[self setJeOutlet:nil];
[self setTuOutlet:nil];
[self setIlOutlet:nil];
[self setNousOutlet:nil];
[self setVousOutlet:nil];
[self setIlsOutlet:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(#"Master", #"Master");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
#end
First thing I will try to debug is -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method. Is it return values? Try to put NSLog in this method and check it.
Or maybe this will help you:
Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.
The code must handle the case where dequeueReusableCellWithIdentifier answers nil...
static NSString *CellIdentifier = #"VerbCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
#import <UIKit/UIKit.h>
#interface tableview : UIViewController<UITableViewDataSource>
{
NSArray *listOfItems;
}
#property(nonatomic,retain) NSArray *listOfItems;
#end
#import "tableview.h"
#implementation tableview
#synthesize listOfItems;
- (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 ]autorelease];
}
//NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];
cell.textLabel.text = [listOfItems objectAtIndex:indexPath.row];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
listOfItems = [[NSArray alloc] initWithObjects:#"first",#"second",#"third", nil];
//listOfItems = [[NSMutableArray alloc]init];
// [listOfItems addObject:#"first"];
//[listOfItems addObject:#"second"];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-(void)dealloc
{
[listOfItems release];
[super dealloc];
}
#end
2012-04-27 13:33:23.276 tableview test[438:207] -[UIView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6855500
2012-04-27 13:33:23.362 tableview test[438:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIView tableView:numberOfRowsInSection:]: unrecognized selector
sent to instance 0x6855500'
* First throw call stack:
(0x13bb052 0x154cd0a 0x13bcced 0x1321f00 0x1321ce2 0x1ecf2b 0x1ef722 0x9f7c7 0x9f2c1 0xa228c 0xa6783 0x51322 0x13bce72 0x1d6592d
0x1d6f827 0x1cf5fa7 0x1cf7ea6 0x1d8330c 0x23530 0x138f9ce 0x1326670
0x12f24f6 0x12f1db4 0x12f1ccb 0x12a4879 0x12a493e 0x12a9b 0x2282
0x21f5)
terminate called throwing an exceptionCurrent language: auto; currently objective-c (gdb)
#interface tableview : UIViewController....
Instead of UIViewController try using UIView
I think you have missed UITableViewDelegate.
Your code is now incompleted. Your "tableView" is not the real UITableView, it's the UIViewController!
You should have the UITableView instance in your h file, and xib file, then link them each other, and set UITableViewDelegate proprty to your UIViewcontroller class.
Please check out the basic UITableView(Or UITableViewController) samples...
I have a table view in my iOS tabbed application, but I can't run the app, I get this error at runtime:
3/23/12 10:15:23.119 PM CodeCompanion: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "2-view-16" nib but didn't get a UITableView.'
*** First throw call stack:
(0x13bd052 0x154ed0a 0x1365a78 0x13659e9 0x2436ae 0xda5cb 0xf5b89 0xf59bd 0xf3f8a 0xf3e2f 0xf1ffb 0xf285a 0xdbfbf 0xdc21b 0xdd0f1 0x4bfec 0x51572 0x4b72b 0x3abc2 0x3ace2 0x3aea8 0x41d9a 0x12be6 0x138a6 0x22743 0x231f8 0x16aa9 0x12a7fa9 0x13911c5 0x12f6022 0x12f490a 0x12f3db4 0x12f3ccb 0x132a7 0x14a9b 0x2888 0x27e5)
My View Controller header file is below:
#import <UIKit/UIKit.h>
#class LanguageTableViewCell;
#interface LanguagesViewController : UITableViewController {
NSArray *languages;
}
#property (nonatomic, retain) NSArray *languages;
#end
and my implementation file is:
#import "LanguagesViewController.h"
#import "LanguageTableViewCell.h"
#implementation LanguagesViewController
#synthesize languages;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(#"getting cell for row at index path: %i", [indexPath row]);
LanguageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"languageBase"];
if (cell == nil) {
cell = [[LanguageTableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:#"languageBase"];
}
[cell setName:[languages objectAtIndex:[indexPath row]]];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(#"rows in section: %i is: %i", section, [languages count]);
return [languages count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
NSLog(#"getting number of sections (1)");
return 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(#"view loaded, setting array");
languages = [NSArray arrayWithObjects:#"Java", nil];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#end
I'm pretty new to xcode and objective-c, so mention anything that could have gone wrong. I have set the ViewController of the table view to my above class, and I am not getting any errors or warnings in xcode. The table view is one of those dynamic ones that use prototype cells. If I need to post the class of the cell, I will.
By the looks of your error message you're using a nib file, "2-view-16", to layout your view but it doesn't contain a UITableView (or it isn't hooked up).
The LanguagesViewController inherits from UITableViewController which is looking for a UITableView to control which doesn't exist.
If you're using a nib to setup the view, you'll need to add a UITableView to the nib and set it to be the tableView of your LanguagesViewController.
This code copied anywhere else seems to work. It's just inside my app where it crashes. Any ideas why?
another .m...
#import "JEntryTableViewController.h"
#interface JCreateViewController () {
JEntryTableViewController *_tableView;
}
#property (nonatomic, strong) JEntryTableViewController *tableView;
#end
#implementation JCreateViewController
#synthesize tableView = _tableView;
- (id)init
{
self = [super init];
if (self) {
self.tableView = [[JEntryTableViewController alloc] initWithStyle:UITableViewStylePlain];
[self.view addSubview:self.tableView.view];
}
return self;
}
JEntryTableViewController.h:
#import <UIKit/UIKit.h>
#interface JEntryTableViewController : UITableViewController {
}
#end
JEntryTableViewController.m:
#import "JEntryTableViewController.h"
#interface JEntryTableViewController ()
#end
#implementation JEntryTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"CountryCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
}
#end
I ran this as a quick test to make sure it was set up right, and to my surprise, when i scroll back to a cell I've already seen, it crashes and gives me a EXC_BAD_ACCESS error. Unfortunately the debugging area isn't giving me anything back that I can work with, and i really don't know what the problem is - it's such a basic, simple bunch of code. I don't know what to fix. It should work.
You way to implement the tableView may not the usual way we often do.
You can add the tableView directly into a ViewController without using another viewController inherit from UITableViewController.
What you should do is identically as what you did in JEntryTableViewController.
When come to the EXC_BAD_ACCESS problem, there are several solutions to find the exact problem.
1. EXC_BAD_ACCESS signal received
http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/
at the right section of Xcode you can add these kind of break points, it may help you find the exception quickly in your case.
two things:
write <UITableViewDataSource, UITableViewDelegate> in
JEntryTableViewController.h file
write down the crash log here so that we can easily solve your problem.