【问题标题】:iOS TableView Referencing outletiOS TableView 参考插座
【发布时间】:2015-02-24 11:58:53
【问题描述】:

我无法将引用插座连接到情节提要上的 showTableView。我只能连接到视图。我试图用一些数据显示表格视图。这是我正在使用的代码。请帮助我。谢谢。

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;
}

【问题讨论】:

    标签: ios objective-c cocoa-touch uitableview uistoryboard


    【解决方案1】:

    确保您已在界面中将UIViewController 的自定义类设置为ViewController,以便您可以正确地将其出口(包括showTableView)链接到ViewController

    【讨论】:

    • @user5 太好了,您可以单击我的答案旁边的复选标记然后将其标记为正确吗?
    • 我做到了。再次感谢您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多