草庐IT

ios - 在 View Controller /页面 View Controller 中全屏显示图像(快速)

我正在使用UIPageViewController来全屏显示图像。问题是图像没有全屏显示。相反,图像和页面控件View点之间的底部以及顶部有一个间隙。我有一个UIViewController,它作为subview/subview添加到UIPageController,并且ViewController具有使用ImageView显示的图像。我正在尝试在swift/storyboard中执行此操作。我在Storyboard中将顶部栏和底部栏选项更改为“无”,但它不起作用。图片预览:ChildViewControllerCode:classBoatContentViewController:U

ios - self.view?.presentScene : unexpectedly found nil while unwrapping an Optional value (Swift)

我正在尝试切换场景,但我的应用程序崩溃并出现此错误:crashcrashfatalerror:unexpectedlyfoundnilwhileunwrappinganOptionalvalue(lldb)这是我切换场景的代码:funcswitchscenes(){ifdisplay>=2{Player.removeFromParent()PlayerRight.removeFromParent()PlayerLeft.removeFromParent()fireHair.removeFromParent()fireHairRight.removeFromParent()fireHai

ios - 无法使用 Firebase 的 MLKit 从图像中检测条形码

因此,我正在尝试使用MLKit扫描条码,但是self.barcodeDetector?.detect的完成block中的条码变量中没有条码。UIImage(命名为:“barcode.jpg”)存在并正确加载(并且有条形码)。那么我做错了什么/我错过了什么?privatevarbarcodeDetector:VisionBarcodeDetector?privatelazyvarvision=Vision.vision()overridefuncviewDidLoad(){super.viewDidLoad()guardletbarcodeImage=self.imageView.ima

swift - 当不在闭包中时,传递属于 self 的函数是否会导致保留循环?

如果您需要在闭包中引用self,最好将其作为weak或unowned传递以防止保留循环。如果我直接传递属于self的函数,会不会造成retaincycle?或者它是否需要嵌套在闭包中以削弱self?直接传递UIView.animateWithDuration(0.3,delay:0.0,usingSpringWithDamping:0.7,initialSpringVelocity:0.1,options:.CurveEaseOut,animations:self.view.layoutIfNeeded,//doesthiscauseretaincycle?completion:nil

uitableview - Swift - 搜索时禁用 refreshControl

在搜索过程中,我想禁用下拉刷新机制。所以我禁用了刷新控件并将其删除。但是当下拉刷新时会调用beginRefresh方法,单元格会保持下拉状态2秒,就像刷新一样。funcsearchBarShouldBeginEditing(searchBar:UISearchBar)->Bool{resultSearchController.searchBar.selectedScopeButtonIndex=0refreshControl!.enabled=falserefreshControl?.removeFromSuperview()returntrue} 最佳答案

ios - 禁用 UIPageViewController 弹跳 - Swift

这个问题在这里已经有了答案:DisableUIPageViewControllerbounce(16个答案)关闭5年前。我一直在制作一个在UIViewControllers之间滚动的示例应用程序,但关键是我想在滚动结束时以及返回到第一个UIViewController。这是我的代码:classPageViewController:UIPageViewController,UIPageViewControllerDataSource,UIPageViewControllerDelegate{varindex=0varidentifiers:NSArray=["FirstNavigatio

ios - 如何快速将静态单元格拖入 tableView?

我的Storyboard中有一个tableView,我在其中添加了4个静态单元格,我的Storyboard看起来像:我的tableView没有任何数据源,因为我的单元格是静态的。我使用下面的代码来拖动一个单元格,它工作正常,直到我滚动一个表格。importUIKitclassTableViewController:UITableViewController{varsourceIndexPath:NSIndexPath=NSIndexPath()varsnapshot:UIView=UIView()letlongPress:UILongPressGestureRecognizer={le

swift - 有没有办法检查 `unowned` (实际上是 `unowned(safe)` )引用已被取消?

有什么方法可以检查unowned(safe)Swift引用的“可用性”?所以,我在这个例子中寻找一个像isReferenceAccessible这样的假设函数:funcsomeMethod(){someAsyncOperation(parameters){[unowned(safe)self]inguardisReferenceAccessible(self)else{return}self.someAnotherMethod()}}免责声明:这个问题与weak引用无关!我知道strong、unowned和weak引用有效。而且我不想使用weak引用(因为它可能很慢且可变)。我知道un

ios - 屏幕的实际尺寸比我看到的要大

我正在学习Swift和SpriteKit。我在Xcode6中创建了新的SpriteKit&Swift游戏项目并编辑了文件GameScene.swift。我没有碰其他文件。问题:当球弹跳时,它受到顶部和底部的限制,但当它向左侧或右侧移动时,它不受限制并消失,但似乎右侧和左侧限制在那里,但它们不在屏幕边缘因为球过一会儿又回来了。这是我的GameScene.swift:importSpriteKitclassGameScene:SKScene{overridefuncdidMoveToView(view:SKView){self.backgroundColor=SKColor.whiteCo

Swift 协议(protocol)定义返回 self 的类方法

我的代码在XCode6beta中工作,但最近在更新到xcode6.1后停止工作。这是我的协议(protocol):protocolCanDeserialiseFromJson{classfuncFromJson(json:JSONValue)->Self}这是实现:extensionInvoice:CanDeserialiseFromJson{classfuncFromJson(json:JSONValue)->Self{returnInvoice()}}这没有给出错误:'Invoice'isnotconvertableto'Self'正如我所说,这曾经有效,但我不明白为什么它不再有效