我已经使用XCode 4.2版本升级到iOS 5。 因为我已经升级,我无法创建合适的工作台视图控制器。在iOS 5 TableViewController没有滚动,也没有调用didSelectRowAtIndexPath
1)表视图被示出在该设备上,但是当我尝试向上滚动,它崩溃没有任何错误信息
2)当我尝试选择一个单元格,didSelectRowAtIndexPath方法不被调用。
NOTE: the same code was workign for me before upgrating to iOS5.
这是TableViewController.m代码文件
#import "CTableViewController.h"
@implementation CTableViewController
@synthesize arrNames;
-(id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
NSLog(@"CTableViewController::initWithStyle");
// Custom initialization
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
arrNames = [[NSMutableArray alloc]initWithObjects:@"Peter Frank Brauer",@"Robert Schneider",@"Winfried Walter Kem",@"Eugen Germen Bachle",@"Clara Weib",@"Heinz Guther Winkler",@"Roland Bendel",@"Swen Aschemeyer",@"Patrick Bodingmeier",nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.arrNames 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];
}
// Configure the cell...
cell.textLabel.text = [self.arrNames objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:16];
NSLog(@"CTableViewController::cellForRowAtIndexPath");
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"called didSelectRow method");
}
@end
谢谢,请帮忙 的Suse
我有完全相同的问题,并修整解决现在2周,并没有运气:(如果有人有解决方案请帮助! – 2012-08-01 18:23:00
当我使用'UITableView'子类,我也得到了同样的问题。我它的工作我已经改变了类UIViewController'的'子类之后。我没有在代码中没有其他变化。 – Ananth 2012-08-03 09:34:19
你已经启用了“所有异常”断点?这应该给你,为什么应用程序崩溃详细 @Ananth如果你在一个UIViewController(而不是UITableViewController)中使用UITableView,你需要自己设置委托和数据源(你也应该声明你的视图控制器符合UITableViewDelegate和UITableViewDataSource协议) – Moxy 2012-08-05 00:30:34