我有桌子,我想点击单元格,它带我到另一张桌子。 在Xcode 4.3.2中运行时出现此错误:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RanchForecastTouchAppDelegate class]));
Thread 1: Signal SIGABRT
我在这个论坛上看到了很多与此错误相关的答案,但它没有用,这就是我再次提问的原因。
我的代码是: 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
控制台上的错误消息:
[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'
编辑:
#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
答案 0 :(得分:0)
你在行尾添加了分号
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{ ...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{....
}
删除它们
答案 1 :(得分:0)
检查您的用户界面连接,这将是一些错误的连接!