小编Van*_*dal的帖子

从String(Swift)中删除前六个字符

删除字符串前六个字符的最佳方法是什么?通过Stack,我发现了几种应该是解决方案的方法,但我发现它们有错误.例如,

extension String {
func removing(charactersOf string: String) -> String {
    let characterSet = CharacterSet(charactersIn: string)
    let components = self.components(separatedBy: characterSet)
    return components.joined(separator: "")
}
Run Code Online (Sandbox Code Playgroud)

如果我输入像https://youtube.com这样的网站,并将其存储为名为网站的变量,请输入以下内容

website.removing(charactersOf: "https://")
Run Code Online (Sandbox Code Playgroud)

它删除了https://部分,但它也从文本中删除了所有h,所有t,:等等.

我怎样才能删除第一个字符?

}

string character swift

13
推荐指数
3
解决办法
1万
查看次数

GMSPlaceField构建时出错-Swift 4.2

我有一个正在使用Google的Place Autocomplete的应用程序,因此我一直在遵循提供的示例代码。我已将GooglePlace窗格添加到我的Podfile中,并且由于我使用的是相同的全屏控件,因此我使用的是示例代码。

在尝试构建项目之前,没有错误显示,在构建时,我收到此错误:第29行上的“使用未声明的类型'GMSPlaceField'”

在此处输入图片说明

xcode google-places-api swift google-places-autocomplete

5
推荐指数
1
解决办法
1183
查看次数

UITextView 与第一响应者混合的占位符文本

我目前有一个带有占位符文本的文本视图,每当用户点击文本视图时,占位符文本就会消失,并且如果文本视图为空,则每当第一响应者辞职时,文本视图中的文本就会重新出现。(这是我使用的代码,以防有人想使用它)

\n\n

*注意,首先将textview的文本颜色设置为浅灰色,并设置占位符文本。然后使用这些方法:

\n\n
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {\n    //If it begins editing, then set the color to black\n    if (textView.tag == 0){\n        textView.text = ""\n        textView.textColor = .black\n        textView.tag = 1\n    }\n    return true\n}\n\n\nfunc textViewDidEndEditing(_ textView: UITextView) {\n    if textView.text.isEmpty {\n        textView.text = "Example: I started my career as a street wear model based in Maryland. After 3 years of working with some of the top companies there, I moved to LA, where I currently reside. I\xe2\x80\x99ve …
Run Code Online (Sandbox Code Playgroud)

uitextview swift

3
推荐指数
1
解决办法
7307
查看次数

GoogleSignIn:GIDSignInResult 类型的值没有成员“身份验证”

我最近更新了当前版本的 GoogleSignIn,但找不到解决我面临的这个问题的方法。我收到的错误是:“GIDSignInResult”类型的值没有成员“身份验证”

func googleSignInAction(){
        guard let clientID = FirebaseApp.app()?.options.clientID else { return }
        let config = GIDConfiguration(clientID: clientID)
        
        GIDSignIn.sharedInstance.signIn(withPresenting: self) { user, error in
            if let error = error {
                print("There is an error signing the user in ==> \(error)")
                return
            }

            guard let authentication = user?.authentication, let idToken = authentication.idToken else { return }
            let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: authentication.accessToken)

            Auth.auth().signIn(with: credential) { authResult, error in
                if error != nil {
                    print(error)
                } else {
                    self.email = …
Run Code Online (Sandbox Code Playgroud)

xcode ios cocoapods swift google-signin

2
推荐指数
1
解决办法
1101
查看次数