- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个带有数组的tableview
。我的数组中有 7 个项目。但是在 cellForRowAtIndexPath
方法中,我无法获得 indexpath.row == 6
。可能是什么原因。代码如下。
-(void)viewDidLoad
{
[super viewDidLoad];
self.menu = [NSArray arrayWithObjects:@"Home",@"ansCategory",@"askQue",@"myQue",@"likedQue", @"topQue", @"topUser",nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
// NSLog(@"count::::::%d",self.menu.count);
return self.menu.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
NSLog(@"rows:%@",indexPath);
NSLog(@"row:%@",[self.menu objectAtIndex:indexPath.row]);
}
return cell;
}
我正在关注:
[这里] ( https://www.dropbox.com/s/pz6t34xr7l4glxz/menu1.png )
第一个索引覆盖在最后一个上。
最佳答案
细胞被重复使用。将您的日志语句放在 if(cell=nil)
之外:
这是在 TableView 中输出数组内容的工作示例。数组中第七个索引为 6 的项目(“topUser”)为红色。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
NSLog(@"rows:%@",indexPath);
NSLog(@"row:%@",[self.menu objectAtIndex:indexPath.row]);
cell.textLabel.text = self.menu[indexPath.row];
if (indexPath.row == 6)
cell.textLabel.textColor = [UIColor redColor];
return cell;
}
关于ios - indexpath.row 显示的行数较少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18201749/
我正在使用Visual Studio 2012和Web Essential 2012,而Less生成的css与预期的不一样 //style.less .selector{ max-heig
我创建了一个基于LESS的小型混合器,用于以标准或视网膜格式输出图像。我无法理解将变量包装在与此相伴的一些CSS URL中-当我编译下面的代码时,我最终得到 url('http://sample.co
有人可以帮助我使用 CSS(less)吗,因为我似乎还不能理解它是如何工作的,我已经通过 node.js 安装了它,但现在如何将它链接到我的代码/网页? 由于某种原因,选择框没有输出到网页上,因为很可
我知道大多数算术运算只能使用按位运算符( Add two integers using only bitwise operators? 、 Multiplication of two integers
我需要在 less 中选择一个类的第 n 个子元素,而不是计算特定类的元素。例如,给定: 李 li class="skip_this" 李 李 李 我想让第 n 个 child 在计数时跳过 skip
当我单击一个按钮时,我进行了一个 ajax 调用,该调用将不同的 html 代码加载到一个 ID 为“main”的 div 中。我可以毫无问题地显示 html 代码,但我找不到将 css 和 js 代
我正在使用非常有限的 Shell 开发嵌入式 Linux。内置命令非常少。 我想检查 gpio 端口。这适用于以下内容。但它需要很多 CPU/IO - 电源!!所以我想像 sleep 一样得到短暂的休
我是一名优秀的程序员,十分优秀!