I create a simple demo with storyboard on Xcode 7 with iOS9. The demo creates a tableview where the UITableViewCell contains a single UILabel. All the UI is defined on storyboard.
However, after running the demo, the app shows an empty table. Is there someone have the same problem?
[updated the UITableViewCell code]
Cell.h
#import <UIKit/UIKit.h>
@interface Cell : UITableViewCell
@property IBOutlet UILabel *label;
@end
Cell.m
#import <Foundation/Foundation.h>
#import "Cell.h"
@implementation Cell
- (void)awakeFromNib {
// Initialization code
//[self.contentView addSubview:self.label]; //uncomment this line, it will work correctly. But in iOS7/8, we do not need to add this line.
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
ViewController.m
#import "ViewController.h"
#import "Cell.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Cell * cell = [tableView dequeueReusableCellWithIdentifier:@"testCell"];
cell.label.text = @"good";
NSLog(@"cell =%@, %@", cell.label, [cell.label superview]);
return cell;
}
@end