2014-12-27 60 views
0

我无法将参考插座连接到故事板上的showTableView。我只能连接查看。我试图用一些数据显示tableview。这里是我使用的代码。请帮助我,谢谢。iOS TableView参考插座

ViewController.h 
@interface ViewController : UIViewController<UITableViewDataSource, UITableViewDelegate> 

@property(nonatomic, strong) IBOutlet UITableView *showTableView; 


ViewController.m 
#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
#warning Potentially incomplete method implementation. 
// Return the number of sections. 
return 1; 
} 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
// Return the number of rows in the section. 


return [jsonResults count]; 

} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath  *)indexPath 
{ 
NSString *simpleIdentifier = @"SimpleIdentifier"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleIdentifier]; 

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:simpleIdentifier]; 
} 

// Configure the cell... 

NSDictionary *appsdict = [jsonResults objectAtIndex:indexPath.row]; 

NSString *nameString = [appsdict objectForKey:@"name"]; 

cell.textLabel.text = [appsdict objectForKey:@"name"]; 
cell.textLabel.textColor = [UIColor whiteColor]; 
cell.textLabel.font = [UIFont boldSystemFontOfSize:12]; 

return cell; 
} 

回答

0

确保您在界面上设置你的UIViewController的自定义类来ViewController,所以你可以将其网点(包括showTableView)正确链接到ViewController

enter image description here

+0

谢谢。它为我工作。 – user5 2014-12-27 17:55:25

+0

@ user5太棒了,您可以点击我答案旁边的复选标记,然后将其标记为正确吗? – 2014-12-27 18:07:27

+0

我做到了。再次感谢你。 – user5 2014-12-28 17:42:55