小编Joh*_*ood的帖子

swift 3日期选择器仅显示日月

我在swift 3中使用以下代码来调出日期选择器.

import UIKit


class ViewController: UIViewController, UITextFieldDelegate {
    @IBOutlet var eventStartText: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()

    eventStartText.delegate = self

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: TextField Delegate
func datePickerChanged(sender: UIDatePicker) {
    let formatter = DateFormatter()
    //formatter.dateStyle = .full
    formatter.dateStyle = .long
    formatter.timeStyle = .none
    eventStartText.text = formatter.string(from: sender.date)

    print("Try this at home")
}

func textFieldDidBeginEditing(_ textField: UITextField) …
Run Code Online (Sandbox Code Playgroud)

swift3 xcode8

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

substring(from:)' 已弃用。使用字符串切片下标和“部分范围来自”运算符

我刚刚在 Xcode 10.1 上将应用程序从swift3转换为swift4.2

我正在修复一些已出现的错误。显然 substring(from:)' 已被弃用。使用字符串切片下标和“部分范围来自”运算符

t_prefix_phone = contact_phone.substring(to:contact_phone.index(contact_phone.startIndex, offsetBy: 3))

t_phone = contact_phone.substring(from:contact_phone.index(contact_phone.endIndex, offsetBy: -7))
Run Code Online (Sandbox Code Playgroud)

您能否帮我将上面的代码翻译为 4.2,使结果仍然是字符串。

谢谢

swift4.2 xcode10.1

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

用3快速登录Facebook

请帮我登录Facebook

我从放入豆荚开始

pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
and then run pod install
Run Code Online (Sandbox Code Playgroud)

之后,我已经将其导入到我的viewController中

import UIKit
import FacebookCore
import FacebookLogin

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let loginButton = LoginButton(readPermissions: [ .publicProfile ])
    loginButton.center = view.center
    view.addSubview(loginButton)
}

    override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    }


}
Run Code Online (Sandbox Code Playgroud)

我用Facebook数据更新了info.plist

用户授权应用后,如何获取用户基本资料?AppDelegate文件中包含什么?

谢谢

ios8 swift3

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

在 UIScrollView Swift3 中加载 UIViewController

我有 2UIViewController秒。一个UIViewController有很多按钮的视图,高+2000点。另一个UIViewController有一个UIScrollView.

这是我的代码:

import UIKit

 class ViewController: UIViewController {

@IBOutlet weak var scrollView: UIScrollView!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


    scrollView.contentSize = CGSize(width: 375, height: 2884)

    DispatchQueue.main.async {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let thumb_vc = storyboard.instantiateViewController(withIdentifier: "thumb") as! ThumbsViewController
        //self.present(vc, animated: true, completion: nil)

    self.addChildViewController(thumb_vc)
    self.scrollView.addSubview(thumb_vc.view)
   }
 } 
Run Code Online (Sandbox Code Playgroud)

尽管拇指UIViewController加载到UIScrollView,但大小错误且不滚动。

任何帮助表示赞赏

ios swift3 xcode8

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

标签 统计

swift3 ×3

xcode8 ×2

ios ×1

ios8 ×1

swift4.2 ×1

xcode10.1 ×1