Tag: swift3

无法识别的select器发送到实例Swift 3

我想用selector实现TapGestureRecognizer ,下面是我添加tapGestureRecognizer到我的imageView的代码 let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:))) firstImageView.isUserInteractionEnabled = true firstImageView.tag = 1 firstImageView.addGestureRecognizer(tapFirstGestureRecognizer) 这是行动方法 func assignImage(_ sender: UIImageView){ imagePicker.allowsEditing = false imagePicker.sourceType = .photoLibrary imageViewTag = sender.tag present(imagePicker, animated: true, completion: nil) } 编译器不断的说 [UITapGestureRecognizer标记]:无法识别的select器发送到实例0x6080001a7700'

使用Tab Bar Controller时,是否可以打开某个button?

这个问题有点混淆,所以希望图像会更有帮助。 这是设置: 所以,我想要第一个视图button打开FirstViewController ,我想第二个视图button来打开SecondViewController 。 如果我将第二视图button链接到SecondViewController像这样: 我失去了标签导航。 如果我把这个button连接到TabViewController像这样: 那么它会自动打开到FirstViewController 。 除非我错过了一些东西,这似乎需要做一点额外的代码,但我似乎无法find任何解释如何做到这一点。 谢谢!

ISO8601DateFormatter不parsingISOdatestring

我试图parsing这个 2017-01-23T10:12:31.484Z 使用由iOS 10提供的原生ISO8601DateFormatter类,但总是失败。 如果string不包含毫秒,则创buildDate对象时没有问题。 我试过这个和许多options组合,但总是失败… let formatter = ISO8601DateFormatter() formatter.timeZone = TimeZone(secondsFromGMT: 0) formatter.formatOptions = [.withInternetDateTime, .withDashSeparatorInDate, .withColonSeparatorInTime, .withColonSeparatorInTimeZone, .withFullTime] 任何想法? 谢谢!

擦除时图像变得模糊和缩小

我正在使用擦除图像的function,我的代码如下所示。 你可以看到这里的video 。 这里current_sticker_img是我的Imageview 注意: 我也使用Pan Gesture来缩放图像 //MARK: Eraser touch event override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { if btn_eraser.isSelected == true || btn_repaint.isSelected == true{ let touch : UITouch = touches.first! lastpoint = touch.location(in: current_sticker_img) } } override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { if btn_eraser.isSelected == true || btn_repaint.isSelected […]

如何自动生成NSManagedObject子类与date而不是NSDatedate属性?

我目前正在更新我的项目Swift 3,我将所有的NSDate方法和扩展到date,以保持在应用程序的标准。 问题是,我使用Xcode来自动生成我的NSManagedObject子类,它生成date属性作为NSDate而不是date。 有没有一种方法来生成date属性为Date? 编辑 按照Apple开发者文档 : Core Data本身支持多种属性types,如string,date和整数(分别表示为NSString,NSDate和NSNumber的实例)。 所以我认为这是不可能的= /

致命错误:对类使用未实现的初始化'init(size :)'

我正在不同的设备上testing我的应用程序,并意识到精灵的移动是非常不一致的(与其他设备相比,在某些设备上运行的速度要快得多)。 我发现这篇文章,并按照说明,并从我所有的SKScene s中删除大小参数,然后我得到了错误: fatal error: use of unimplemented initializer 'init(size:)' for class 'SuperGame.PosterScene' 请参阅下面的PosterScene类和调用它的PosterScene类。 PosterScene class PosterScene: SKScene { override init(){ super.init() let posterImage = SKSpriteNode(imageNamed: "poster") posterImage.position = CGPoint(x: self.frame.midX, y: self.frame.midY) self.addChild(posterImage) let sequence = SKAction.sequence([ SKAction.wait(forDuration: 3.0), SKAction.run({ self.changeToMainMenuScene() }) ]) self.run(sequence) } func changeToMainMenuScene () { let mainMenuScene = MainMenuScene() self.view!.presentScene(mainMenuScene) […]

在获取聊天logging的同时,我没有从Openfire获取两个用户历史logging

我从openfire中通过在明火中安装开放式火狐插件来获取历史logging,并尝试使用此代码。 let iq1 = DDXMLElement(name: "iq") iq1.addAttribute(withName: "type", stringValue: "get") iq1.addAttribute(withName: "id", stringValue: "0") let retrieve = DDXMLElement(name: "retrieve", xmlns: "urn:xmpp:archive") retrieve?.addAttribute(withName: "with", stringValue: "raman@ip-172-31-53-77.ec2.internal") let set = DDXMLElement(name: "set", xmlns: "http://jabber.org/protocol/rsm") let max = DDXMLElement(name: "max", stringValue: "50") iq1.addChild(retrieve!) retrieve?.addChild(set!) set?.addChild(max) stream?.send(iq1 ) 现在我没有从双方获得历史。 这是我得到的结果。 <iq xmlns="jabber:client" type="result" id="0" to="bentick@ip-172-31-53-77.ec2.internal/5qsinh1syg"> <chat xmlns="urn:xmpp:archive" with="raman@ip-172-31-53-77.ec2.internal" start="2017-02-07T06:28:33.691Z"> […]

Swift 3打开链接

我试图在点击button时运行这个函数: @IBAction func openLink(_ sender: UIButton) { let link1 = "https://www.google.com/#q=" let link2 = birdName.text! let link3 = link2.replacingOccurrences(of: " ", with: "+") //EDIT let link4 = link1+link3 guard let query = link4.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed), let url = NSURL(string: "https://google.com/#q=\(query)") else { return } UIApplication.shared.openURL(URL(url)) } 但是,最后一行被标记为“不能调用非函数types的值”UIApplication“。这个语法是从这里开始的,所以我不确定是怎么回事。

如何使用Swift 3制作一个button的animationanimation

我有一个函数每3秒调用一次。 我怎样才能摇晃左右摇晃的buttonanimation。 func shakeButton() { if opened == false { //Shake Animation } }

尝试访问紧凑模式下的UITextView时,iMessage扩展崩溃

以下是我在iMessage应用程序中的完整代码。 class MessagesViewController: MSMessagesAppViewController { @IBOutlet weak var messageView: UITextView! fileprivate func setupMessageView() { messageView.delegate = self messageView.layer.cornerRadius = 10 messageView.layer.borderColor = UIColor.black.cgColor messageView.layer.borderWidth = 5 messageView.text = "Tap to enter a message" messageView.textColor = UIColor(red:0.80, green:0.81, blue:0.82, alpha:1.0) messageView.textAlignment = .center messageView.font = UIFont.systemFont(ofSize: 20) messageView.textContainerInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: […]