不明白为什么 cellForRowAtIndexPath 从未被调用,即使 numberOfRowsInSection 被调用我调用这个 ViewController
ServerDataController *dataController = [[ServerDataController alloc] initWithNibName:@"ServerDataController" bundle:nil];
[self presentModalViewController:dataController Animation:YES];
这是我的代码: 头文件:
#import <UIKit/UIKit.h>
@interface ServerDataController : UIViewController <NSXMLParserDelegate, NSURLConnectionDelegate, UITableViewDataSource>
{
...
NSMutableArray *items;
UITableView *docsTableView;
}
@property (retain, nonatomic) IBOutlet UITableView *docsTableView;
@property (nonatomic, readonly) NSMutableArray *items;
@end
实现文件:
#import "ServerDataController.h"
@implementation ServerDataController
@synthesize docsTableView;
@synthesize items;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (id)init
{
self = [super init];
if (self)
{
}
return self;
}
- (void)dealloc {
[items release];
[docsTableView release];
[super dealloc];
}
- (void)viewDidAppear:(BOOL)animated
{
[self fetchEntries];
animated = YES;
}
- (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
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if (self) {
items = [[NSMutableArray alloc] init];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[self items] 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] autorelease];
}
NSString *cellTitle = [[[[items objectAtIndex:indexPath.row] docUrl] lastPathComponent] stringByDeletingPathExtension];
cell.textLabel.text = cellTitle;
return cell;
}
有什么建议么?