0
我有一個問題,我有一個UITableView在我的UIViewController,但是當我添加內容到我的UITableView並重新加載數據什麼也沒有發生。在UIViewController的Xcode UITableView does not顯示內容
我的UIViewController:
@interface WPCreateViewController : UIViewController<UITableViewDelegate, UITableViewDataSource, UIActionSheetDelegate> {
....
@property (strong, nonatomic) IBOutlet UITableView *tableViewEntities;
@property (strong, nonatomic) NSMutableArray *entities;
....
- (IBAction)cancel:(id)sender;
- (IBAction)save:(id)sender;
- (IBAction)addEntities:(id)sender;
- (IBAction)deleteEntities:(id)sender;
}
和實現是這樣的:
@implementation WPCreateViewController
- (void)viewDidLoad{
[super viewDidLoad];
....
[self.tableViewEntities setAllowsMultipleSelectionDuringEditing:YES];
[self.entities setArray:[[NSMutableArray alloc] init]];
....
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.entities count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellID = @"WPEntityCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
}
cell.textLabel.text = [[self.entities objectAtIndex:indexPath.row] name];
cell.detailTextLabel.text = [[self.entities objectAtIndex:indexPath.row] description];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {
}
,如果我嘗試添加的東西什麼也不會發生,因爲我說的,我有這個方法有一個按鈕連接
- (IBAction)addEntities:(id)sender {
Entity *temp = [[Entity alloc] init];
temp.name = @"Test";
temp.description = @"TestTest";
[self.entities addObject:temp];
[self.tableViewEntities reloadData];
}
順便說一句,所有的連接都正確設置,那麼爲什麼uitableview不笑什麼都可以嗎?
我在界面生成器,那並不窩即使我做的代碼 – user1882812
如果設置在numberOfSectionsInTableView斷點這樣做已經方法,它不斷受到打擊? – Lance