系统自带的 pickerView,假如我现在给的datasource 为1--60 的数,在pickerview中,假设 滚轮上小于18的数(行),不能点击(不参与交互),大于或者等于的正常使用。
在tableview中可以这样
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...............
..............
if (indexPath.row < 18) {
cell.userInteractionEnabled = NO;
}
...............
...............
}
有类似的实现吗?
在tableview中可以这样
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...............
..............
if (indexPath.row < 18) {
cell.userInteractionEnabled = NO;
}
...............
...............
}
有类似的实现吗?
如果是UITableView,则使用下面代码即可:- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row>=18) {
// Do user interactions
}
}
{
if (indexPath.row < 18) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else {
cell.selectionStyle = UITableViewCelLSelectionStyleDefault;
}
}
或者,进行一些特殊的定制,例如将cell的backgroundColor设置为lightGray