ios - UISlider 不在原型(prototype)单元中滑动
<p><p><strong>我在 Storyboard 的 ViewController 中设计了一个原型(prototype)单元格,但不幸的是单元格中的 <code>UISlider</code> 没有滑动。</strong></p>
<p><strong>注意:-</strong>此 Storyboard 已启用自动布局。</p>
<p>设计:-</p>
<p> <a href="/image/tmcXx.png" rel="noreferrer noopener nofollow"><img src="/image/tmcXx.png" alt="enter image description here"/></a> </p>
<p><strong>这里是代码:-</strong> 在 <code>UITableview</code></p> 中渲染单元格
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if(indexPath.row!=self.arrSelectRecipientsImages.count-1 )
{
cell = ;
}
else
{
cell = ;
UISlider *sliderNearby = (UISlider *);
lblDistance = (UILabel *);
sliderNearby.userInteractionEnabled = YES;
forState:UIControlStateNormal];
;
}
return cell;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我认为代码运行良好。
也无需设置用户交互。</p>
<p>这是示例代码,您可以从中获得帮助。使用自动布局可以正常工作。</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = ;
UILabel *lblTitle = (UILabel *);
lblTitle.text = @"Hi";
UISlider *slider = (UISlider *);
slider.value = 0.2;
slider.tag = indexPath.row;
;
return cell;
}
- (void)sliderNearbyAction:(UISlider *)sender{
NSLog(@"Slider %ld Value : %.2f",(long)sender.tag, sender.value);
}
</code></pre>
<p><strong>带日志的输出:</strong></p>
<p> <a href="/image/6TsPM.png" rel="noreferrer noopener nofollow"><img src="/image/6TsPM.png" alt="enter image description here"/></a> </p>
<p><strong>自动布局屏幕截图:</strong> </p>
<p> <a href="/image/ruLac.png" rel="noreferrer noopener nofollow"><img src="/image/ruLac.png" alt="enter image description here"/></a> </p></p>
<p style="font-size: 20px;">关于ios - UISlider 不在原型(prototype)单元中滑动,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34488856/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34488856/
</a>
</p>
页:
[1]