解決済み:実際には解決策ではありませんが、ストーリーボードを使用しようとするのではなく、.xib を使用しました。私がストーリーボードでやろうとしていたことは、何らかの形で TableView デリゲート メソッドが呼び出されないようにすることでした。皆さんが提供してくれたすべての洞察に感謝します。
配列で設定する必要がある UITableView を含む UIViewController があります。残念ながら、UITableView は配列によって取り込まれません (空ではありません)。
私の .h ファイル:
@interface Directory : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate> {
NSArray *listData;
NSArray *savedListData;
MKMapView* mapUI;
UISearchBar* searchBar;
NSArray * originalListData;
UITableView* placeList;
DirInfoListing *infoInst;
NSString *searchInit;
NSString *openInit;
NSMutableArray *buildings;}
@property (nonatomic, retain) NSArray *listData;
@property (nonatomic, retain) NSArray *savedListData;
@property (nonatomic, retain) IBOutlet UISearchBar* searchBar;
@property (nonatomic, retain) IBOutlet UITableView* placeList;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil list: (NSArray*)array mapView:(MKMapView*) map;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil list:(NSArray*)array mapView:(MKMapView*) map search:(NSString*) ss;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil list: (NSArray*)array mapView:(MKMapView*) map open:(NSString*) openTx;
-(void)doDBLoad;
@end
そして、私の .m ファイルからの関連するもの:
#import "Directory.h"
@interface Directory ()
@end
@implementation Directory
@synthesize listData, savedListData;
@synthesize searchBar;
@synthesize placeList;
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"ListData count: %lu", (unsigned long)savedListData.count);
//This returns a valid number of 74 items
return [self.savedListData count];
}
/*
* Populates the table with list data and provides title. AND DOES NOT GET CALLED
*/
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *tID = @"tablIDDirect";
UITableViewCell *c = [tableView dequeueReusableCellWithIdentifier:tID];
if(c == nil) {
c = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:tID];
}
NSInteger r = [indexPath row];
if([self.listData objectAtIndex:r] != nil){
c.textLabel.text = ((DBBuilding*)[self.savedListData objectAtIndex:r]).Name;
c.detailTextLabel.text = ((DBBuilding*)[self.savedListData objectAtIndex:r]).Acronym;
}
c.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return c;
}
/*
* Displays an entry according to the table selection and redirects the user to the Directory Information Listing.
*/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger r = [indexPath row];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(infoInst != nil) {
infoInst = nil;
}
infoInst = [[DirInfoListing alloc] initWithNibName:@"DirInfoListing" bundle:nil building:[self.savedListData objectAtIndex:r] map:mapUI];
}
/*
* Notification that the Directory is the active view
*/
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(openInit != nil)
{
[self openEntry:openInit];
openInit = nil;
}
placeList = [[UITableView alloc] init];
placeList.dataSource = self;
placeList.delegate = self;
[placeList reloadData];
}
/*
* Notification that the Directory is no longer the active view
*/
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (void)viewDidLoad
{
NSLog(@"ListData count: %lu", (unsigned long)listData.count);
//Also returns a valid number of 74 objects within the array
savedListData = [[NSArray alloc] initWithArray:listData];
//That get put into another array just for my sanity
[super viewDidLoad];
// Do any additional setup after loading the view.
searchBar.text = searchInit;
[self performSearch:searchInit];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
メソッドは呼び出されますが、他の-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
UITableView デリゲート メソッドは呼び出されず、なぜこれが起こるのか途方に暮れています。
また、このコード全体のチャンクは、.xibs を使用して (正しく動作する) 私のアプリの別の 1 つから取得され、ストーリーボードを使用しません。このアプリ (私が問題を抱えているアプリ) は、私がよく知らないストーリーボードを使用しています。ストーリーボードの呼び出しと使用に問題がある可能性がありますが、よくわかりません。それに関連する何かがあるかもしれませんが、私はより多くの情報を提供できます。
私のコードを調べて、どこが間違っているのか見てください。ありがとう!