- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 UIViewController 中有一个 UITableView,我想我已经完成了所有必要的步骤设置它,但是当我把一个 NSLog 放在它的协议(protocol)的 requiered 方法中时,我没有得到 tableView 的响应
我告诉 UITableView 我将实现它的协议(protocol)
@interface SubSelectionTableViewWithMenuVC : UIViewController <CustomTableViewCellDelegate,
UITableViewDelegate,
UITableViewDataSource,
TableViewModelDelegate>
我在标题中设置了 tableView socket
@property (weak, nonatomic) IBOutlet UITableView *tableView;
在 ViewDidLoad
中,我将委托(delegate)设置为 self。
self.tableView.delegate = self;
self.tableView.dataSource = self;
然后我实现了所需的委托(delegate)方法
– tableView:cellForRowAtIndexPath:
– tableView:numberOfRowsInSection:
但是没有任何反应,我在 tableView 对象的 ViewDidLoad 中做了一个 NSLog,它告诉我:
tableView: <UITableView: 0x1d43aa00; frame = (0 0; 0 0); clipsToBounds = YES;
autoresize = TM+BM; gestureRecognizers = <NSArray: 0x1cdc54f0>; layer = <CALayer:
0x1cdc5350>; contentOffset: {0, 0}>
必需的委托(delegate)方法:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSLog(@"num of sections");
return 1;
}
#pragma mark - UI set cell contents
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cell for row at indepath");
static NSString *CellIdentifier = CELL_IDENTIFIER_LECTURES;
CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.indexPath = indexPath;
cell.delegate = self;
// Configure cell
[cell.mainLabel setText:[self titleForRow:indexPath.row]];
[cell.numberLabel setText:[NSString stringWithFormat:@"%i", indexPath.row + 1]];
cell.state = [self restoreTagButtonStateForCell:cell];
// perform selector on cell to update and show its last stored state
if ([cell respondsToSelector:@selector(updateButtonImageState)]) {
[cell performSelector:@selector(updateButtonImageState)];
} else {
[NSException raise:NSGenericException format:@"cell does not respond to selector"];
}
// Setting the Highligthed color of selected cell
UIView *goldenColor = [[UIView alloc] init];
goldenColor.backgroundColor = [UIColor colorWithRed:0.824 green:0.749 blue:0.553 alpha:1.0f];
cell.selectedBackgroundView = goldenColor;
return cell;
}
最佳答案
原因是因为您没有实现– tableView:numberOfRowsInSection:
方法。实现此方法并返回您需要的金额。
关于ios - 在 ViewController 中设置了 TableView 的数据源和委托(delegate),但没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18477661/
我正在尝试将高斯模糊添加到场景中。我正在使用此GLSL着色器:。当您提供图像作为tDiffuse纹理时,它对图像起作用,但我正在尝试将其添加为后处理效果。我试图获取摄影机的renderTarget并将
我正在做一款天气应用程序,到目前为止还不错。现在,我想通过单击按钮来呈现一些额外的信息。我有一个5天的预报,然后想显示每一天的信息。我已经成功地过滤了数据,但无法获得要渲染的数据地图。以下是我的一些代
我正在做一款天气应用程序,到目前为止还不错。现在,我想通过单击按钮来呈现一些额外的信息。我有一个5天的预报,然后想显示每一天的信息。我已经成功地过滤了数据,但无法获得要渲染的数据地图。以下是我的一些代
我在全球安装了Create Reaction应用程序。然后我就跑了。NPX创建-反应-应用JSX。它安装了大约1460个包的所有包,但没有设置Public和src文件夹。在我的JSX文件夹中,只有1:
我是一名优秀的程序员,十分优秀!