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;
}
謝謝。它爲我工作。 – user5 2014-12-27 17:55:25
@ user5太棒了,您可以點擊我答案旁邊的複選標記,然後將其標記爲正確嗎? – 2014-12-27 18:07:27
我做到了。再次感謝你。 – user5 2014-12-28 17:42:55