我在以模式方式使用视图控制器作为登录页面时遇到问题。我可以让控制器出现,但无法更改其全尺寸。
我试图在屏幕中央呈现带有褪色背景的弹出框。当我在视图之外单击时,弹出窗口应该关闭。
我浏览了整个网站的问题和答案,但没有找到对我有用的问题和答案。
这是我的代码:
import UIKit
class SignInView: UIViewController, UIPopoverPresentationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "popoverSegue" {
var popover = segue.destination as! SignInPopView
popover.popoverPresentationController!.delegate = self
popover.modalPresentationStyle = UIModalPresentationStyle.popover
popover.preferredContentSize = CGSize(width: 375, height: 500)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Firebase 数据库,并且正在尝试使用NSObject. 我NSUnknownKeyException在运行应用程序时收到错误,导致它崩溃。
NSObject:
class WatchList: NSObject {
var filmid: Int?
}
Run Code Online (Sandbox Code Playgroud)
火力基地代码:
class WatchList: NSObject {
var filmid: Int?
}
Run Code Online (Sandbox Code Playgroud)
我不确定是什么原因造成的。
此外,为了加强这方面的办法就是让他们借此数据,而不是使用NSObject的,使用的方式Codable,并JSONDecoder与火力地堡数据?
我试图根据B列中的三个最大数字找到G列的平均值.
我试过的公式是:
=AVERAGEIF(B7:B131,LARGE(B7:B131,{1,2,3}),G7:G131)
Run Code Online (Sandbox Code Playgroud)
问题是它不对三者进行平均,而是仅显示相当于B列中最大数字的G列.
有人知道在这种情况下使用的正确公式吗?
我试图在 swift 4 中将 URL 图像设置为 UIButton。我正在使用 AFNetworking 从 URL 加载我的图像。我正在了解将图像设置为按钮的最佳途径是什么。
使用.setImage()或setImageWith()不适用于 urls 和 uibuttons。
这是正在使用的 URL:
let imageUrl = URL(string: baseUrl + profile)
我有一个水平集合视图,每次点击按钮时都会添加一个新单元格。每次点击按钮时,一旦单元格不再可见,我就会尝试将集合视图滚动到下一个单元格。
我现在拥有的代码无法正常工作
代码:
@IBAction func random(_ sender: Any) {
resultsCollection.reloadData()
let collectionBounds = resultsCollection.bounds
let contentOffset = CGFloat(floor(resultsCollection.contentOffset.x - collectionBounds.size.width))
self.moveToFrame(contentOffset: contentOffset)
}
func moveToFrame(contentOffset : CGFloat) {
let frame: CGRect = CGRect(x : contentOffset ,y : resultsCollection.contentOffset.y ,width : resultsCollection.frame.width,height : resultsCollection.frame.height)
resultsCollection.scrollRectToVisible(frame, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题,以便在我点击按钮时它可以正确滚动?