Ich habe einige Probleme, bei denen meine UITableView nicht neu lädt, ich habe die Verknüpfung der Steckdose neu gemacht, um sicherzustellen, dass das nicht das Problem war. Ich habe auch versucht, [Selbsttabelle] reloadData] zu verwenden, aber das scheint auch nicht zu funktionieren. Ich habe die Probleme debugged, aber es überspringt einfach reloadData und die App läuft weiter, als wäre der Code nicht da.numberOfRowsInSection wird nicht für UITableView aufgerufen
Top Teil meiner .m-Datei ist nichts in ViewDidLoad
#import "SettingsCourses.h"
@implementation SettingsCourses
@synthesize settingsCourses;
@synthesize Delegate;
@synthesize BackButton;
@synthesize DeleteButton;
@synthesize table;
@synthesize courses;
@synthesize dataHandler;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
dataHandler = [[DataHandler alloc] init];
dataHandler.coursesDelegate = self;
courses = [dataHandler fetchCourses];
NSLog(@"Debug Count: %i", [courses count]);
}
[table reloadData];
return self;
}
- (void) viewWillAppear:(BOOL)animated {
[table reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (courses) {
NSLog(@"Count: %i", [courses count]);
return [courses count];
}
else {
NSLog(@"Count: 0");
return 0;
}
}
getan
Meine .h-Datei
#import <UIKit/UIKit.h>
#import "dataHandler.h"
@interface SettingsCourses : UIViewController
@property (strong, nonatomic) DataHandler *dataHandler;
@property (strong, nonatomic) NSMutableArray *courses;
@property (strong, nonatomic) IBOutlet UIView *settingsCourses;
@property (nonatomic, strong) id Delegate;
@property (weak, nonatomic) IBOutlet UIButton *BackButton;
@property (weak, nonatomic) IBOutlet UIButton *DeleteButton;
@property (weak, nonatomic) IBOutlet UITableView *table;
- (IBAction)Delete:(id)sender;
- (IBAction)Back:(id)sender;
Vielen Dank für jede Hilfe!
Haben Sie die DataSource der Tabellenansicht festgelegt? – UIAdam
Ist die Tabelle mit dem 'delegate' und der' dataSource' in der xib verbunden? Hast du die 'UITableViewDelegate' und' UITableViewDataSource' in der .h Datei hinzugefügt? – Mat