我为应用程序创建原型,该应用程序使用完全相同的UITableViewController类文件用于两种不同的方案。
要清楚,以下是第二种情况的外观:
请记住,两者都使用完全相同的类文件。 第一种情况完美运行,而第二种情况仅在长按时调用didSelectRowAtIndexPath
,而按钮则完全不起作用。
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("fires") // scenario 2 does not fire until long press
if selectable {
guard let cell = tableView.cellForRowAtIndexPath(indexPath) else { return }
cell.accessoryType = (cell.accessoryType == .Checkmark) ? .None : .Checkmark
}
}
我的表格视图控制器嵌入在容器视图中,如何在点按而不是长按时触发didSelectRowAtIndexPath?
答案 0 :(得分:1)
我有一个类似的问题,这是由于容器视图没有实现触摸方法并通过调用super将它们传递给链:
print ("This is where you run the python model")
adult_population = Gen0.adult_population
birth_rate = Gen0.birth_rate
juvenile_population = Gen0.juvenile_population
juvenile_survival = Gen0.juvenile_survival
adult_population = Gen0.adult_population
adult_survival = Gen0.adult_survival
senile_population = Gen0.senile_population
senile_survival = Gen0.senile_survival
disease = Gen0.disease
disease_trigger = Gen0.disease_trigger
generations = Gen0.generations
counter = 0
while counter < generations:
new_juvenile_population = adult_population * birth_rate
new_adult_population = juvenile_population * juvenile_survival
new_senile_population = (adult_population * adult_survival) + (senile_population * senile_survival)
new_total = new_juvenile_population + new_adult_population + new_senile_population
print("Juveniles:" ,new_juvenile_population)
print("Adults:" ,new_adult_population)
print("Seniles:" ,new_senile_population)
print("Total population:" ,new_total)
juvenile_population = new_juvenile_population
adult_population = new_adult_population
senile_population = new_senile_population
counter += 1
我在容器中没有任何触控功能,但仍然需要调用并传递链,以便我的表视图对它们起作用。