-1
をトリガしません* dataController = [[ServerDataControllerのalloc] initWithNibName: "ServerDataController" バンドル@: nil];cellForRowAtIndexPathがnumberOfRowsInSectionが、私は</p> <p>ServerDataControllerでこのViewControllerをを呼び出す と呼ばれているにもかかわらず、cellForRowAtIndexPathが呼び出されない理由を理解することはできません
[self presentModalViewController:dataController animated: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;
}
任意の提案ですか?
XMLファイルの解析中にアイテムを追加しましたが、そのコードを非常に大きなものとして含めませんでした。配列は必ず空ではありません。 cellForRowAtIndexPathはとにかく起動するはずです – Oleg
長時間の撮影ですが、私のコードを書いてみると愚かなことに驚かされます:)コントローラがUIViewControllerで、UITableViewControllerでないのはなぜですか?私はUITableViewDelegateを実装する必要があると思う、もしあなたがUITableViewControllerの代わりに通常のUIViewControllerであれば – verhage