我在 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/
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
有时我需要处理键/值数据。我不喜欢使用数组,因为它们在大小上没有限制(很容易不小心添加超过2个项目,而且您最终需要稍后验证大小)。此外,0和1的索引变成了魔数(MagicNumber),并且在传达含义方面做得很差(“当我说0时,我的意思是head...”)。散列也不合适,因为可能会不小心添加额外的条目。我写了下面的类来解决这个问题:classPairattr_accessor:head,:taildefinitialize(h,t)@head,@tail=h,tendend它工作得很好并且解决了问题,但我很想知道:Ruby标准库是否已经带有这样一个类? 最佳
我正在处理旧代码的一部分。beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)endRubocop错误如下:Avoidstubbingusing'allow_any_instance_of'我读到了RuboCop::RSpec:AnyInstance我试着像下面那样改变它。由此beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)end对此:let(:sport_
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
我正在尝试使用Curbgem执行以下POST以解析云curl-XPOST\-H"X-Parse-Application-Id:PARSE_APP_ID"\-H"X-Parse-REST-API-Key:PARSE_API_KEY"\-H"Content-Type:image/jpeg"\--data-binary'@myPicture.jpg'\https://api.parse.com/1/files/pic.jpg用这个:curl=Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")curl.multipart_form_
无论您是想搭建桌面端、WEB端或者移动端APP应用,HOOPSPlatform组件都可以为您提供弹性的3D集成架构,同时,由工业领域3D技术专家组成的HOOPS技术团队也能为您提供技术支持服务。如果您的客户期望有一种在多个平台(桌面/WEB/APP,而且某些客户端是“瘦”客户端)快速、方便地将数据接入到3D应用系统的解决方案,并且当访问数据时,在各个平台上的性能和用户体验保持一致,HOOPSPlatform将帮助您完成。利用HOOPSPlatform,您可以开发在任何环境下的3D基础应用架构。HOOPSPlatform可以帮您打造3D创新型产品,HOOPSSDK包含的技术有:快速且准确的CAD
本教程将在Unity3D中混合Optitrack与数据手套的数据流,在人体运动的基础上,添加双手手指部分的运动。双手手背的角度仍由Optitrack提供,数据手套提供双手手指的角度。 01 客户端软件分别安装MotiveBody与MotionVenus并校准人体与数据手套。MotiveBodyMotionVenus数据手套使用、校准流程参照:https://gitee.com/foheart_1/foheart-h1-data-summary.git02 数据转发打开MotiveBody软件的Streaming,开始向Unity3D广播数据;MotionVenus中设置->选项选择Unit