关于 "com.github.scopt" %% "scopt" % "3.3.0" ,
"com.typesafe.akka" %% "akka-testkit" % "2.3.8" % "test",
"com.typesafe.play" %% "play-test" % "2.3.8" % "test",
"com.tinkerpop.gremlin" % "gremlin-java" % gremlinVersion,
"com.tinkerpop" % "pipes" % gremlinVersion,
"com.thinkaurelius.titan" % "titan-core" % titanVersion,
"com.thinkaurelius.titan" % "titan-cassandra" % titanVersion,
"com.thinkaurelius.titan" % "titan-berkeleyje" % titanVersion,
"com.netaporter" %% "scala-uri" % "0.4.8",
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"com.mandubian" %% "play-json-zipper" % "1.2",
"com.michaelpollmeier" %% "gremlin-scala" % "2.6.1",
"com.ansvia.graph" %% "blueprints-scala" % "0.1.61-20150416-SNAPSHOT",
"io.kanaka" %% "play-monadic-actions" % "1.0.1" exclude("com.typesafe.play", "play_2.11"),
"org.scalaz" %% "scalaz-concurrent" % "7.0.6",
"com.chuusai" %% "shapeless" % "2.3.0-SNAPSHOT",
("io.github.jto" %% "validation-json" % "1.0").exclude("org.tpolecat", "tut-core_2.11"),
"org.parboiled" %% "parboiled" % "2.1.0",
"com.typesafe.scala-logging" %% "scala-logging" % "3.1.0",
"ch.qos.logback" % "logback-classic" % "1.1.2",
"xxx.xxxxxxxxxx" %% "chuck" % "0.9.0-SNAPSHOT",
"xxx.xxxxxxxxxx" %% "shed-graph" % "0.9.0-MOK-1848-SNAPSHOT" exclude("com.thinkaurelius.titan", "titan-core"),
"io.circe" %% "circe-core" % "0.2.0-SNAPSHOT",
"io.circe" %% "circe-generic" % "0.2.0-SNAPSHOT",
"io.circe" %% "circe-jawn" % "0.2.0-SNAPSHOT"
我使用UICollectionViewDelegate
以及didHighlightItemAtIndexPath
didSelectItemAtIndexPath
按预期工作。也就是说,当我单击遥控器时,此代码将运行。
问题是didSelectItemAtIndexPath
也在点击时运行,当名称显示此块仅在突出显示时运行。我错过了什么吗?
各个街区:
didHighlightItemAtIndexPath
额外备注
对于func collectionView(collectionView: UICollectionView, didHighlightItemAtIndexPath indexPath: NSIndexPath) {
let node: XMLIndexer = self.xml!["ArrayOfVideo"]["Video"][indexPath.row]
let title = (node["Title"].element?.text)!
let date = (node["Date"].element?.text)!(node["SpeakerOrganization"].element?.text)!
self._title.text = title
self._date.text = date
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
let node: XMLIndexer = self.xml!["ArrayOfVideo"]["Video"][indexPath.row]
let videoUrl = (node["VideoURL"].element?.text)!
self.playVideoByUrlString(videoUrl)
}
我通过添加以下内容来获取单元格图像上的视差感觉:
UICollectionViewCell
覆盖// self is a UICollectionViewCell
// self.imageView is a UIImageView
self.imageView.adjustsImageWhenAncestorFocused = true
self.imageView.clipsToBounds = false
代理中的shouldUpdateFocusInContext
答案 0 :(得分:3)
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] randomForest_4.6-12 e1071_1.6-7 caret_6.0-58 ggplot2_1.0.1 lattice_0.20-33 doParallel_1.0.10 iterators_1.0.8
[8] foreach_1.4.3
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 magrittr_1.5 splines_3.2.2 MASS_7.3-44 munsell_0.4.2 colorspace_1.2-6 minqa_1.2.4 stringr_1.0.0
[9] car_2.1-0 plyr_1.8.3 tools_3.2.2 nnet_7.3-11 pbkrtest_0.4-2 grid_3.2.2 gtable_0.1.2 nlme_3.1-122
[17] mgcv_1.8-8 quantreg_5.19 snow_0.3-13 class_7.3-14 MatrixModels_0.4-1 lme4_1.1-10 digest_0.6.8 Matrix_1.2-2
[25] nloptr_1.0.4 reshape2_1.4.1 codetools_0.2-14 stringi_1.0-1 compiler_3.2.2 scales_0.3.0 stats4_3.2.2 SparseM_1.7
[33] proto_0.3-10
安排, didHighlightItemAtIndexPath
之前调用的方法didSelectItemAtIndexPath
。每次触摸单元格时,它都会在您选择之前突出显示(出于视觉目的,我假设)。你可以通过这个例子看到它:
UICollectionView
当我触摸单元格输出
时func collectionView(collectionView: UICollectionView, didHighlightItemAtIndexPath indexPath: NSIndexPath) {
print("highlight")
}
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("select")
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath)
let imageView = UIImageView(frame: CGRect(origin: CGPointZero, size: cell.frame.size))
imageView.image = imageFromColor(UIColor.redColor(), size: cell.frame.size)
imageView.highlightedImage = imageFromColor(UIColor.blueColor(), size: cell.frame.size)
cell.addSubview(imageView)
return cell
}
func imageFromColor(color: UIColor, size: CGSize) -> UIImage {
let rect = CGRectMake(0, 0, size.width, size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(rect)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}
如果您希望突出显示或选择细胞,请仅查看highlight
select
方法UICollectionViewDelegate's
,shouldHighlightItemAtIndexPath
。您可以通过在shouldSelectItemAtIndexPath
内查看indexPath
来阻止选中突出显示的单元格。