ios - 滚动tableview计数标签值改变了吗?
<p><pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *simpleTableIdentifier = @"PickAClassCell";
cell = (PickAClassCell *);
if (cell == nil)
{
NSArray *nib = [ loadNibNamed:@"PickAClassCell" owner:self options:nil];
cell = ;
}
cell.CountLabel.tag=1000;
return cell;
}
-(void)PlusButtonSelect :(UIButton *)sender
{
UILabel *label1 = (UILabel *);
int count = ;
count = count + 1;
label1.text = ;
NSLog(@"%@",label1);
}
</code></pre>
<p>这是我的代码,当我单击 <code>PlusButtonSelect</code> 时计数会增加。问题是当我的表格 View 滚动时,计数标签变为零。 </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>终于找到答案了,这里的<code>myData</code>是NsMutableArray。首先基于 <code>No of Row</code> 我们可以取 myData 中的第一个零。
在 <code>cellForRowAtIndexPath</code></p>
<pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *simpleTableIdentifier = @"PickAClassCell";
cell = (PickAClassCell *);
if (cell == nil)
{
NSArray *nib = [ loadNibNamed:@"PickAClassCell" owner:self options:nil];
cell = ;
}
cell.CountLabel.text=];
cell.CountLabel.tag=1000;
;
return cell;
}
-(void)PlusButtonSelect :(UIButton *)sender
{
UILabel *label1 = (UILabel *);
NSLog(@"%@",label1);
int count = ;
count = count + 1;
NSString *Strcount= ;
;
;
}
</code></pre>
<p>减号按钮也一样。</p></p>
<p style="font-size: 20px;">关于ios - 滚动tableview计数标签值改变了吗?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41057554/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41057554/
</a>
</p>
页:
[1]