ios - 如何禁用UITableView的节索引的用户交互?

标签 ios objective-c uitableview

我已经在应用程序中实现了表索引右侧的部分索引,该字母允许快速跳转至部分。在某些情况下,我想禁用用户与该节索引的交互,但是UITableView上没有允许直接访问节索引的属性。

如何禁用节索引的用户交互?

我已禁用了与表本身的交互,因此您无法滚动或点击任何单元格,但这仍然允许与节索引进行交互,因此在点击节图标时它将滚动到每个节。

self.tableView.userInteractionEnabled = NO;

如果无法禁用与节索引本身的交互,是否有办法防止更改表的滚动位置?那正是我想要获得的。

最佳答案

或者,如果您希望允许滚动-用户可以看到那里的内容-但阻止他们进行选择等,则可以执行以下操作:

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.tableViewIsDidabled)
        return nil;
    else
        return indexPath;
}

并将sectionForSectionIndexTitle设置为nil。

关于ios - 如何禁用UITableView的节索引的用户交互?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24943596/

相关文章:

ios - 如何在 Swift 4 中用 ascii 空格填充文本框输入提醒字节?

ios - 离线使用 Mapkit

ios - 使 UITextView 多行

ios - 如何清除 Restkit 中 UITableView 的 NSFetchedResultsController 结果

ios - 如何将 UITableViewCell 放到 UITableView 的底部。

iphone - 如何从用户那里识别 UITableView Cell Touchup 超过 5 秒

iOS - 无法访问 UITableViewCell 类中的 UITextView 委托(delegate)

ios - 德尔福,FireMonkey : How to find unique hardware id in OSX and iOS

ios - 对 NSDictionary 的 NSArray 进行排序...未完全正常工作

objective-c - 查找与特定字符串匹配的 NSString NSArray 的索引?