在iOS 11中,PDFKit已在iOS中提供.它具有使用UIPageViewController的功能,但不能设置过渡样式(文档).
有没有什么方法可以将PDFView的PageViewController的转换样式从默认更改为页面卷曲?
我想在集合视图中重新排序每个单元格的自定义大小的单元格.
在Collection View的每个单元格中都有一个带有单词的标签.
我用这段代码设置每个单元格的维度:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let word = textArray[indexPath.row]
let font = UIFont.systemFont(ofSize: 17)
let fontAttributes = [NSFontAttributeName: font]
var size = (word as NSString).size(attributes: fontAttributes)
size.width = size.width + 2
return size
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码重新排序集合视图:
override func viewDidLoad() {
super.viewDidLoad()
self.installsStandardGestureForInteractiveMovement = false
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(gesture:)))
self.collectionView?.addGestureRecognizer(panGesture)
}
func handlePanGesture(gesture: UIPanGestureRecognizer) {
switch gesture.state {
case UIGestureRecognizerState.began :
guard let selectedIndexPath = self.collectionView?.indexPathForItem(at: gesture.location(in: …Run Code Online (Sandbox Code Playgroud) 我已根据Firebase指南在我的iOS应用中使用Firebase实施了Google SignIn.问题是每次我测试登录时,它总是要求权限.

以下是Google SignIn中涉及的AppDelegate代码:
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return GIDSignIn.sharedInstance().handle(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) …Run Code Online (Sandbox Code Playgroud) 我\xe2\x80\x99m 尝试构建一个 Swift 包,该包包装了一个用 C: libndi_advanced_ios.a编写的胖静态库,来自NewTek\'s Apple Advanced NDI SDK。
\n我在将预编译库(只有头文件和 .a 二进制包可用)链接到我的 Swift 包时遇到问题。我做了很多研究并尝试了不同的解决方案,但没有一个有效。这是一个快速列表:
\n无法捆绑在 XCFramework 中,因为libndi_advanced_ios.a支持多个平台(arm_v7、i386、x86_64、arm64)并xcodebuild -create-xcframework返回错误( Swift 论坛binaries with multiple platforms are not supported上也讨论了此解决方案);
按照SPM 文档(已过时)的建议使用.linkedLibraryin会发出警告,并且我什至不记得它是否构建成功;targetssystem packages are deprecated; use system library targets instead
使用不同的标志和设置(如linkerSettings)并没有成功。也许我只是错过了正确的组合。
我可以链接数十个 Stackoverflow 的问题和其他没有帮助的帖子,但它们毫无用处(a、b、c)。
\n目前我有这样的配置: …
static-libraries ios swift swift-package-manager swift-package
在 iPad 上的ActionSheeta 内使用 SwiftUI 时List,它出现在错误的位置,尤其是当列表的样式设置为 时GroupedListStyle。
使用此代码:
struct ContentView: View {
@State var presentAction: Bool = false
var body: some View {
NavigationView {
List {
Section {
Button(action: {
self.presentAction.toggle()
}) {
Text("Present")
}
.actionSheet(isPresented: $presentAction) {
ActionSheet(title: Text("This is an action sheet"), buttons: [
.destructive(Text("Destroy all"))
])
}
}
}.listStyle(GroupedListStyle())
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
Run Code Online (Sandbox Code Playgroud)
结果如下图所示(iPad Pro 10.5"):
但在我当前的应用程序中,情况更糟:
我有一个拆分视图控制器,当用户单击表视图中的单元格时,该应用程序会显示一个带有容器视图和段控件的视图控制器,以在两个子视图控制器之间切换.
第一个子视图控制器是Collection View Controller.在Collection View的每个单元格中都有一个单词.
该视图如下所示:
我使用此代码以编程方式添加子视图控制器(来自详细视图控制器,子视图的容器):
override func viewDidLoad() {
self.currentViewController = self.storyboard?.instantiateViewController(withIdentifier: "WordCollectionViewControllerID")
(self.currentViewController as! WordCollectionViewController).text = self.text
self.currentViewController?.view.translatesAutoresizingMaskIntoConstraints = false
self.addChildViewController(self.currentViewController!)
self.addSubview(subView: self.currentViewController!.view, toView: self.textContainerView)
self.currentViewController?.view.layoutIfNeeded()
self.currentViewController?.didMove(toParentViewController: self)
super.viewDidLoad()
}
func addSubview(subView: UIView, toView parentView: UIView) {
parentView.addSubview(subView)
var viewBindingsDict = [String: AnyObject]()
viewBindingsDict["subView"] = subView
parentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[subView]|", options: [], metrics: nil, views: viewBindingsDict))
parentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[subView]|", options: [], metrics: nil, views: viewBindingsDict))
}
Run Code Online (Sandbox Code Playgroud)
以下是使用分段控件在两个子视图之间切换的代码:
@IBAction func changeChildViewController(_ sender: UISegmentedControl) {
if sender.selectedSegmentIndex == 0 {
let newViewController …Run Code Online (Sandbox Code Playgroud) 我已在我的 iOS 项目中添加了 Google 登录 Firebase,但按钮 ( GIDSignInButton) 文本未居中,我想将其居中 ( Sign-in with Google)。
我的存储目录中有一个主"文件夹" users-projects,然后我为每个用户的项目创建文件夹.我想允许用户仅访问他们的项目以及邀请他们参与的项目,例如带有协作者的Dropbox或Google Drive文件夹.
他们在文档中说:
在文件元数据中包括组信息(例如组ID或授权uid列表)
所以这是我的问题:
我正在使用Swift编写iOS应用程序.
这是我的规则的实际代码:
service firebase.storage {
match /b/on-team.appspot.com/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
match /users-projects {
match /{projectId} {
allow read, write: if ?????
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是官方文档:https://firebase.google.com/docs/storage/security/user-security.