swift3

didDiscover peripheral not called

点点圈 提交于 2019-12-20 06:27:15
问题 I want to use the CBCentralManager in order to find the bluetooth low energy peripherals around me. The centralManager is getting initiated, it starts correctly and it is scanning. But the didDiscover function is never called. I read all the other posts to this and similar problem and am 99% sure that my problem has not the same cause. Still, I cannot find what I did wrong. import Foundation import CoreBluetooth @objc(SmallerBeaconServiceImpl) class SmallerBeaconServiceImpl : NSObject,

Cannot receive event with custom DelegateProxy and Protocol

让人想犯罪 __ 提交于 2019-12-20 06:24:54
问题 I try to migrate delegate of DifficultyViewDelegate to observable. This is my DifficultyViewDelegate : @objc protocol DifficultyViewDelegate: class { func levelDidIncrease() func levelDidDecrease() } And my DifficultyView : weak var delegate: DifficultyViewDelegate? @IBAction func decreaseLevel(_ sender: Any) { delegate?.levelDidDecrease() } @IBAction func increaseLevel(_ sender: Any) { delegate?.levelDidIncrease() } And this is my RxDifficultyViewDelegateProxy class

Cannot invoke initializer for type 'AnyObject?' with no arguments

痴心易碎 提交于 2019-12-20 06:07:11
问题 I am using swift 3 to build a type of chat messenger. To store loggedIn Users, I try to use an onject of type AnyObject. var loggedInUser = AnyObject?() And it gives the following error: ViewController.swift:29:24: Cannot invoke initializer for type 'AnyObject?' with no arguments 来源: https://stackoverflow.com/questions/39515792/cannot-invoke-initializer-for-type-anyobject-with-no-arguments

Cannot invoke initializer for type 'AnyObject?' with no arguments

旧城冷巷雨未停 提交于 2019-12-20 06:07:10
问题 I am using swift 3 to build a type of chat messenger. To store loggedIn Users, I try to use an onject of type AnyObject. var loggedInUser = AnyObject?() And it gives the following error: ViewController.swift:29:24: Cannot invoke initializer for type 'AnyObject?' with no arguments 来源: https://stackoverflow.com/questions/39515792/cannot-invoke-initializer-for-type-anyobject-with-no-arguments

How to restrict button click

戏子无情 提交于 2019-12-20 05:38:12
问题 I have a VC like this for the checkBoxes i have embedded UIButtons and i am changing their image on click. Here's my code @IBOutlet weak var bestSellerButton: UIButton! @IBOutlet weak var trendingButton: UIButton! @IBOutlet weak var lowToHighButton: UIButton! @IBOutlet weak var highToLowButton: UIButton! var isBoxClicked = Bool() func updateCheckImageOnClick(button: UIButton) { if isBoxClicked == true { isBoxClicked = false button.setImage(UIImage.init(named: "checkmark"), for: UIControlState

How to create top Navigation like Reddit App in Swift 3

依然范特西╮ 提交于 2019-12-20 05:16:25
问题 Here is the UI i want to create: and what the complete UI looks like: but i want to create first top Navigation. i tried https://github.com/subinspathilettu/SJSegmentedViewController Which is working but it shows navigation after that it shows SegmentView.Could someone help me to create this UI it's same like reddit app screen after login.I need in swift.Thanks in advance 回答1: Okay. Here is the solution. Step 1: Take no. of buttons you want in a UIView. Take UILabel for equal width of each

how to make checkmark to be selected depending on the array in swift 3?

荒凉一梦 提交于 2019-12-20 04:49:27
问题 I am having array in which selected name will be stored and passed to before view controller and when ever i need to go previous view controller then the previously selected check mark needs to be selected but here it is enabling the last selected element only the problem is if i select three then it is not selecting three it is check marking only the last element but i need the three selected can anyone help me how to make the check mark to be selected for three elements ? protocol

how to make checkmark to be selected depending on the array in swift 3?

泄露秘密 提交于 2019-12-20 04:49:03
问题 I am having array in which selected name will be stored and passed to before view controller and when ever i need to go previous view controller then the previously selected check mark needs to be selected but here it is enabling the last selected element only the problem is if i select three then it is not selecting three it is check marking only the last element but i need the three selected can anyone help me how to make the check mark to be selected for three elements ? protocol

Invalid Float value - swift 3 ios

五迷三道 提交于 2019-12-20 04:48:14
问题 I had core data storage, my field "expensesAmount" in Float identify. The value of expensesAmount is 6.3. But when I retrieve it to variable "expensesAmount" as below, it become 6.30000019. So my totalAmount is not correct. Can someone help? let entity:NSManagedObject = data?.object(at: i) as! NSManagedObject if let expensesAmount = entity.value(forKey: "expensesAmount") as? Float { totalAmount += expensesAmount } 回答1: Try Follwoing : let entity:NSManagedObject = data?.object(at: i) as!

Swift: SKSpriteKit, using Storyboards, UIViewController and UIButton to set in game parameters?

五迷三道 提交于 2019-12-20 04:38:44
问题 Context The default code that comes with a new SpriteKit game has a storyboard such that - following the launch screen - all there is, is a GameViewController which calls forth the GameScene . However, this may be less ideal for many games. For example, one may wish to have the user select difficulty from a main menu, and then go to the GameScene - outlined below: Notably, the middle view controller is a custom class MyUIViewController so that the UIButtons "easy" and "hard" can have the