swift3

How to use a view controller as a side menu in Swift3

[亡魂溺海] 提交于 2020-01-05 03:58:05
问题 I am trying to implement the side menu in my application programatically. So I have designed a view controller with half of its view as table view. The design as well as coding is done, now i wish to use this view controller as a Side Menu controller. My SideMenu Storyboard is: Now my code looks like this: import UIKit class SideBarViewController: UIViewController { @IBOutlet weak var menu: UIView! @IBOutlet weak var menuTableView: UITableView! var fieldImages = [UIImage]() var

UIImage from camera is rotated 90 degrees - using extensions

被刻印的时光 ゝ 提交于 2020-01-05 03:47:11
问题 When Image data is returned and applied to a UIImage, if the data comes from the camera then the image appears rotated 90 degrees. I tried adding the extension UIImage { func correctlyOrientedImage() -> UIImage { if self.imageOrientation == UIImageOrientation.up { return self } UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale) self.draw(in: CGRect(origin: CGPoint(x: 0,y :0), size: CGSize(width: self.size.width, height: self.size.height)) ) let normalizedImage:UIImage =

UIScrollView with Content View

戏子无情 提交于 2020-01-05 03:43:12
问题 I've been trying to create a UIScrollView for user registry but with no success. I'm using auto layout and all of the fields that go inside the scroll view are static. Because of the usual ambiguous height issue, I've added a UIView inside the scroll view, set the constraints to the margins of the scroll view and centered aligned it. After that I added all of the fields inside that Content View, in the storyboard. The content fields have their constraints setup as you would expect, but when I

respondToSelector / performSelector with parameter from a string in Swift 3

 ̄綄美尐妖づ 提交于 2020-01-05 03:37:34
问题 I have to call method of a class. This method potentially exists or not. I'm looking for a solution from 2 hours. The following works without parameter sayHello() I have the class : class myClass: NSObject { func say(something:String){ print("I say : \(something)") } func sayHello(){ print("Hello") } } 1st step : Create a selector from a string with a parameter let selector = NSSelectorFromString("sayHello" ) let selectorWithParam = NSSelectorFromString("say:" ) 2nd step : Test if the method

iOS app crashing in release mode, works in debug mode

岁酱吖の 提交于 2020-01-05 02:46:38
问题 Recently my app started breaking if I create the .ipa file for AppStore release. It works fine if I run the same code in emulator or if I run it on my iPhone from xcode, but once I create the release package it crashes while opening a particular view controller. I went through few of the posts on Stackoverflow where people had similar problems and tried following things: Setting SWIFT_OPTIMIZATION_LEVEL = "-Onone"; for release mode Setting GCC_OPTIMIZATION_LEVEL = 0; for release mode

Realm Swift callback function

ε祈祈猫儿з 提交于 2020-01-04 14:15:02
问题 I use swift3 and Realm 2.3. And I need callback after transaction is finished. for example, I have a code as below, how can I get call back after a realm data transaction is finished ? DispatchQueue.main.async { try! self.realm.write { self.realm.add(friendInfo, update: true) } } 回答1: Transactions are executed synchronously. So you can just perform the code right after you execute the transaction. DispatchQueue.main.async { try! self.realm.write { self.realm.add(friendInfo, update: true) }

UISlider track height

≡放荡痞女 提交于 2020-01-04 09:36:40
问题 I have implemented UISlider and I need to adjust track height. I found this but its not working. self.slider.trackRect(forBounds: CGRect(x: 0, y: 0, width: 100, height: 100)) 回答1: found this but its not working Because you're using it wrong. You don't call it. You subclass, and override it. However, the right approach is to supply new images for the track, with setMinimumTrackImage and setMaximumTrackImage . 回答2: Ok...I used matt's answer + provided example and I customized the code for my

Submitting an app to the App Store that uses Firebase

独自空忆成欢 提交于 2020-01-04 09:11:45
问题 I had a quick question about submitting an app to the app store when it uses Firebase. I wanted to know if there is anything I need to do on the Firebase side to enable the database for anyone to use. Or can I just go through the normal process of submitting an app and assume that the database will be working for a tester or any user that downloads the app? In short do I have to enable something on the Firebase side for it to work globally for any user? Any help would be appreciated. 回答1:

Submitting an app to the App Store that uses Firebase

丶灬走出姿态 提交于 2020-01-04 09:11:05
问题 I had a quick question about submitting an app to the app store when it uses Firebase. I wanted to know if there is anything I need to do on the Firebase side to enable the database for anyone to use. Or can I just go through the normal process of submitting an app and assume that the database will be working for a tester or any user that downloads the app? In short do I have to enable something on the Firebase side for it to work globally for any user? Any help would be appreciated. 回答1:

Swift 3 - Pass struct by reference via UnsafeMutableRawPointer?

孤人 提交于 2020-01-04 07:51:49
问题 In the Core Audio -Framework user data can be passed into callbacks via an UnsafeMutableRawPointer? . I was wondering how to pass a struct by reference via this UnsafeMutableRawPointer? . Changes made inside the callback should be reflected outside the callback. I set up a playground to test this: struct TestStruct { var prop1: UInt32 var prop2: Float64 var prop3: Bool } func printTestStruct(prefix: String, data: TestStruct) { print("\(prefix): prop1: \(data.prop1), prop2: \(data.prop2),