草庐IT

indexpath

全部标签

ios - UITableView 中的自动滚动更顺畅

我有一个拖放开关语句,允许用户抓取一个单元格,代码无缝地创建它的快照,然后用户可以将快照拖动到新位置。繁荣!移动单元格。当行/单元格的数量超过iPhone的屏幕时,我添加了代码以允许用户向上/向下拖动表格。iflocationOnScreen.y1{letindexPath=NSIndexPath(forRow:indexPath!.row-1,inSection:0)tableView.scrollToRowAtIndexPath(indexPath,atScrollPosition:UITableViewScrollPosition.Top,animated:false)}else

ios - UICollectionView

我有一个可重复使用的CollectionView单元格。我正在尝试在索引路径的didselect处设置图像,但是当我选择一个单元格时,它返回的结果多于返回相同图像的单元格。这是代码。funccollectionView(collectionView:UICollectionView,numberOfItemsInSectionsection:Int)->Int{return1}funccollectionView(collectionView:UICollectionView,cellForItemAtIndexPathindexPath:NSIndexPath)->UICollect

ios - UICollectionView 快速滚动/滑动到下一个项目

我在ViewController中有一个UICollectionView。当用户单击其中一个图像时,它会转到一个单独的页面以打开图像。我不想每次都返回图库来更改图片,而是向左或向右滑动以获取下一张或上一张图片。我已经看到了执行“pagingEnabled=true”的答案,但是你把它放在哪里呢?我是swift的新手。下面是我的代码。我在这里先向您的帮助表示感谢。ViewController.swiftimportUIKitclassViewController:UIViewController,UICollectionViewDataSource,UICollectionViewDel

ios - 如何覆盖 reloadRowsAtIndexPaths?

我正在尝试覆盖tableView单元格的方法reloadRowAtIndexPath。我想做的和你覆盖cellForRowAtIndexPath时一样:functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{if(isUserTalking(indexPath)){returnuserMessageCell(indexPath)}else{if(isNotUserFirstMessage(indexPath)){returnnotUserFirstM

ios - Segue 可选值 nil

functableView(_tableView:UITableView,didSelectRowAtindexPath:IndexPath){letnewuser=users[indexPath.row]letusernname=newuser.name!asStringprint(usernname)print(keys[indexPath.row])letdestinationViewController=ChatViewController()destinationViewController.toUid=keys[indexPath.row]destinationViewCo

ios - 像 Instagram 这样的图像列表

我想制作一个可滚动的图像列表,例如4列的instagram。我创建了一个带有ImageView的CollectionViewhttp://prntscr.com/d15rnx.但我得到了这个结果-http://prntscr.com/d15tsq代码-//MARK:-UICollectionViewDataSourceprotocol//tellthecollectionviewhowmanycellstomakefunccollectionView(_collectionView:UICollectionView,numberOfItemsInSectionsection:Int)-

ios - 将 UITableView 实例化为弹出窗口时,UITableViewCell 的属性为 nil

我有一个UIViewController和一个UISegmentedControl,当我点击一个segmentedControl段。我遇到的问题是当我单击一个段时,弹出窗口开始加载,但随着myPopoverTableViewController加载而崩溃。它崩溃了overridefunctableView(_tableView:UITableView,cellForRowAtindexPath:IndexPath)->UITableViewCell,说我的PopoverTableViewCell的属性是nil.为简单起见,我将在此处引用我的类(class):myViewControll

ios - 我无法暂停在 tablecell 上播放视频

我曾经使用avplayer在UITableViewCell上加载视频。我可以在UITableViewCell上加载视频,但无法暂停/播放视频。我无法执行任何基本功能,例如增加/减少音量。请任何人帮助我解决这个问题。这是我的代码:functableView(_tableView:UITableView,cellForRowAtindexPath:IndexPath)->UITableViewCell{letcell:FeedCell=tableView.dequeueReusableCell(withIdentifier:"VedioCell",for:indexPath)as!Feed

ios - 错误 :'inout IndexPath' 不可转换为 'IndexPath'

我有一个TableViewController,其中包含使用CoreData的数据条目列表。我还有带TextView的ViewController。我已经完成了对项目的添加、保存和删除等操作。现在我正在通过将选定的TableViewCell链接到下一个ViewController上的TextView来进行编辑。但是,我收到错误消息,因为“inoutIndexPath”无法转换为“IndexPath”。如何解决这个错误? 最佳答案 funcgetIndexPathForSelectedCell()->IndexPath?{varind

ios - collectionView.indexPathsForVisibleItems 没有列出我知道可见的项目

我有一个UICollectionView,它显示的单元格部分包含我需要从服务器获取的图像。在cellForItemAt中,我检查我的缓存以查看图像是否可用,如果不可用,我调用一个方法来下载图像。在该方法中,我异步加载图像。下载图像后,我检查与该图像关联的indexPath是否可见。如果是这样,我调用reloadItems来更新显示。问题是我可以在模拟器上看到空单元格,但它不在可见单元格的数组中。这是显示问题的最小片段。funccollectionView(_collectionView:UICollectionView,cellForItemAtindexPath:IndexPath)