</pre><p></p><pre code_snippet_id="1554467" snippet_file_name="blog_20160112_2_4622891" name="code" class="objc" style="font-size: 18px;">创建了一个viewcontroller继承自tableviewcontroller,在Storyboards 创建 tableview的static cells,但是运行时,显示不出tableview
原因:因为在创建Viewcontroller时,xcode默认帮我们添加了下面的方法
<pre name="code" class="objc">#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
return 0;
}
解决:
我们可以直接删除这些方法,或者按照下面的方式:
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [super numberOfSectionsInTableView:tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [super tableView:tableView numberOfRowsInSection:section];
}