UIViewControllerサブクラスとセットアップデリゲートメソッドでUITableViewControllerを作成しましたが、データソースデリゲートメソッドが(ログを観察して)呼び出されていません。 UITableViewControllerをサブクラス化する必要がありますか?私は何を取りこぼしたか? MyViewController.mUITableViewデリゲートメソッドが呼び出されていない
- (void)viewDidLoad
{
myTableViewController = [[UITableViewController alloc]initWithStyle:UITableViewStylePlain];
myTableViewController.tableView.delegate = self;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
NSLog(@"numberOfRowsInSection");
return [self.assets count]; //assets is NSMutableArray
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"cellForRowAtIndexPath");
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if (!cell) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [assets objectAtIndex:row]; //assets is NSMutableArray
cell.textLabel.font = [UIFont boldSystemFontOfSize:50];
return cell;
}
で
MyViewController.hで
@interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableViewController *myTableViewController;
}
@property (nonatomic, assign) UITableViewController *myTableViewController;
Iは、別のクラスからテーブルビューと呼ばれる:
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:myTableViewController];
私はあなたの解決策ではありませんでしたが、UITableViewDataSourceでは適切な修正を行いました。 – user523234