- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试向我的 UICollectionView 添加一个后退/返回按钮,到目前为止我有这段代码来实现该按钮:
import UIKit
class EmojiPopup: UIView,UICollectionViewDataSource,UICollectionViewDelegate
{
var collocationView : UICollectionView!
var arrImagesList:NSMutableArray!
var blur:UIBlurEffect = UIBlurEffect()
override init(frame: CGRect)
{
super.init(frame: frame)
arrImagesList = NSMutableArray()
self.backgroundColor = UIColor.purpleColor().colorWithAlphaComponent(0.2)
let layout = UICollectionViewFlowLayout()
//header gap
layout.headerReferenceSize = CGSizeMake(20,20)
//collection view item size
layout.itemSize = CGSizeMake(70, 70)
layout.minimumInteritemSpacing = 25
layout.minimumLineSpacing = 25
collocationView = UICollectionView(frame: CGRectMake(50,50,UIScreen.mainScreen().bounds.screenWidth - 100,UIScreen.mainScreen().bounds.screenHeight - 100), collectionViewLayout: layout)
self.addSubview(collocationView)
// Create the blurEffect and apply to view
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.ExtraLight)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.alpha = 0.7
blurEffectView.frame = self.bounds
self.addSubview(blurEffectView)
collocationView.backgroundColor = UIColor.purpleColor().colorWithAlphaComponent(0.002)
collocationView.dataSource = self
collocationView.delegate = self
collocationView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "cellIdentifier")
//hide scrollbar
self.collocationView.showsVerticalScrollIndicator = false
//back button
let btnBack = UIButton(frame:TCRectMake(x:138 ,y:523,width:45,height:45))
btnBack.setImage(UIImage(named:"back"), forState: UIControlState.Normal)
btnBack.addTarget(self, action:"btnBackClick", forControlEvents: UIControlEvents.TouchUpInside)
self.addSubview(btnBack)
//back button func
func btnBackClick()
{
}
let fm = NSFileManager.defaultManager()
let path = NSBundle.mainBundle().resourcePath!
let items = try! fm.contentsOfDirectoryAtPath(path)
for item in items
{
if item.hasSuffix("png") && item.containsString("@") == false && item.containsString("AppIcon") == false && item.containsString("tick_blue") == false && item.containsString("video_camera") == false
{
arrImagesList.addObject(item)
}
}
}
var completeHandler:((String)->())?
func showDetails(viewParent:UIView,doneButtonClick:((String)->())?)
{
completeHandler = doneButtonClick
viewParent.addSubview(self)
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return arrImagesList.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let identifier="ImageCell\(indexPath.section)\(indexPath.row)"
collectionView.registerClass(ImageViewCell.self, forCellWithReuseIdentifier:identifier)
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(identifier, forIndexPath: indexPath) as! ImageViewCell
cell.backgroundColor = UIColor(white:1, alpha:0)
cell.imgView.image = UIImage(named:arrImagesList[indexPath.row] as! String)
cell.imgView.backgroundColor = UIColor.clearColor()
cell.imgView.opaque = false
cell.imgView.contentMode = .ScaleAspectFit
//keeps blur to background
self.bringSubviewToFront(collocationView)
return cell
}
// func collectionView(collectionView: UICollectionView,
// layout collectionViewLayout: UICollectionViewLayout,
// sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
// {
// let width=UIScreen.mainScreen().bounds.size.width-50
// return CGSize(width:width/3, height:width/3)
// }
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
{
//let cell=collectionView.cellForItemAtIndexPath(indexPath) as! ImageViewCell
UIView.animateWithDuration(0.3, animations:{
self.collocationView.alpha=0
}, completion: { finished in
if self.completeHandler != nil
{
self.completeHandler!(self.arrImagesList[indexPath.row] as! String)
}
self.removeFromSuperview()
})
}
func showDetails(viewParent:UIView,dictData : [String:String],index:Int,doneButtonClick:(()->())?,cancelBUttonClick:(()->())?)
{
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
如果用户按下后退按钮,我希望关闭 Collection View ,但我不确定在后退按钮功能中输入什么。如果可能的话,我希望用户返回到主视图 Controller (mapview)
最佳答案
我假设您在谈论 UICollectionViewController
而不是 UICollectionView
。 UICollectionViewController
内部有一个 UICollectionView
。您可以“关闭”(关闭)UICollectionViewController
但不能“关闭”(关闭)UICollectionView
。您甚至可以关闭内部有 UICollectionView
的 UIViewController
。
你有两个选择:
UICollectionViewController
它将再次变得可见。路途遥远。我建议你阅读这个 getting started guide来自 Apple,在那里你可以弄清楚导航 Controller 是如何工作的以及它们的作用。这是您在使用 Swift 进行开发时需要学习的东西。我建议您进一步阅读整个教程。阅读该章后,您应该了解 iOS 应用程序的导航流程并实现后退按钮导航。
如果您在学习该教程时发现任何问题,请告诉我。
关于swift - UICollectionView 上的后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38313041/
浏览器或类似浏览器的应用程序中的后退和前进按钮暂时导航(用户导航页面的顺序),这可能不一定反射(reflect)页面的逻辑顺序。是否有任何研究探讨这如何影响用户的心理模型?关于如何提高可用性和减少困惑
如果你去http://www.deviantart.com/并等待几秒钟,以便在引擎盖下加载 javascript,您可以单击一个链接,而不是转到该链接,您将转到 #/someId。您可以后退/前进。
Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic
This question already has answers here: How to stop audio from playing when back button is pressed?
Visual Studio 有一个名为 MouseNavi 的插件它允许您使用鼠标拇指按钮来浏览您的历史记录。 Eclipse 是否存在类似的扩展? 最佳答案 我不知道有任何 Eclipse 插件可以
我在grails上开发了一个小应用程序,第一页是我提供的邮政编码,可以按商店搜索附近的商店并选择它,然后按下一步按钮,第二页上是输入客户详细信息,然后按下一步按钮在第三页上显示输入的值,然后保存它。现
我有一个带有表单的页面,我试图在其中防止重复提交,这非常简单(以防万一有人好奇,我使用了这个 $("form").submit(function() { setTimeout(function
在过去的两天里,我一直在用一个恼人的小故障敲我的头,希望有人能解释一下。 基本设置:我有一个带有播放器的 AVPlayerLayer, View 中有一个平移手势识别器,我希望用户能够来回滑动手指,视
我有一个相当具体的用例。 假设我从页面 A 导航到页面 B(添加一个历史状态)。然后,在页面 B 上,我通过打开模式与该页面进行交互。但模式的实现方式是在单击浏览器后退按钮时关闭。 当模式打开时: n
我以前自己尝试过,但失败了。如何将 JButton 添加到 JFrame 以将其带回到之前打开的 JFrame 或“主页”框架。 在我的应用程序中,我有 4 个 JFrame,主要的和 3 个可通过按
想法是显示消息,这将通知用户,当他使用“后退”按钮时,应用程序的ajax部分可能会错误地工作。是的,有很多讨论,但没有解决方案。我发现最好的:在服务器端存储有关最后一页的信息,并通过 ajax 检查当
我有一个带有Fragment的Activity,并且有很多交易,所以后退按钮通常只是回滚Fragment交易 .但我需要检测最后一次按下。 我不能使用 onPause 方法,因为我不想在用户按下主页或
我目前使用Glide库播放GIF如下。 Glide.with(this).load(gifUrl).into(ImageView); 这很好用,但我希望用户可以选择倒回、暂停和转发 GIF。我在想只是
我正在开发一个 WPF 桌面应用程序,我有一个主窗口,我使用框架控件导航到不同的页面。它工作得很好。但我希望删除后退/前进。我该怎么做 ?请在这方面帮助我! 最佳答案 设置 NavigationUIV
我正在游戏结束时显示插页式广告。当用户快速按下“后退”按钮时,有时会发生崩溃: java.lang.IllegalStateException at android.media.MediaPlayer
我想禁用导致 Chrome 后退或前进的两指滑动。 我有一个网站,如果用户没有专门保存,他可能会失去工作进度。 我试过使用 window.onbeforeunload但是,如果我在 url 中有哈希值
后退箭头在 Xcode 中损坏? 是否有键盘命令可以一次后退/前进一个文件。 Xcode 3.2更改了 Cmd-Opt 的行为。正如另一个问题中所指出的,它们不像以前版本的 Xcode 那样在文件级
我有这些复选框 Menu Filters Select All Unselect All Vegan Vegetar
我想在按下返回按钮时将我当前的 flutter 页面重定向到主页,将重定向。当我按返回按钮时,主页/ Activity 应开始。我在主页中有多种选择,在当前页面中,如果用户不想选择它们,我可以显示眼睛
按住下一个按钮时,音频播放器速度加快... 代码代表一切 main question : How to continue to normal ? 这是我的尝试 http://jsfiddle.net/
我是一名优秀的程序员,十分优秀!