swift4

How to hide passwords in a UITextField like “*****”?

耗尽温柔 提交于 2021-01-28 10:40:28
问题 How to hide passwords in a UITextField like "*****" ? To hide password, i used following code txtPassword.isSecureTextEntry = true but this will display like “•••••••” , but i need like "*******" 回答1: To achieve the same, you can use a normal textfield without the secure input option. When a user enters a character, save it to a string variable, and replace it in the textfield with the character you wish to present instead of the bullets. Set the textField delegate in viewDidLoad() as:

expandable drop down inside tableview in swift4

好久不见. 提交于 2021-01-28 10:23:44
问题 I tried, expandable drop down inside tableview in swift4 but not worked my below code. if i changed custom model class to String it is working. my requirement use below custom model class. please check my below code. class ExpandViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, ExpandableHeaderViewDelegate { var empDetails = [EmpWorking]() var hiredDetails = [Hired]() @IBOutlet weak var tableView: UITableView! var sections = [SectionData]() override func

ios UICollectionView cell selecting and deselecting issue

人盡茶涼 提交于 2021-01-28 08:23:04
问题 Im using UIcollection view as my tabbar when I scroll collection view horizontally previous selected cell will not deselect when i select new one this is my code to change colour when i select a cell and deselect a cell var selectedIndexPath : IndexPath = [] func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let cell = collectionView.cellForItem(at: indexPath) as? BottomCollectionViewCell { cell.contentView.backgroundColor = UIColor.orange cell

Audio Missing when Adding Text on pixelBuffer

牧云@^-^@ 提交于 2021-01-28 08:18:26
问题 I am trying to add text overlay on video, When recording in iPhone 5s or lower devices in High quality and writing text on that then after 1 or 2 seconds audio goes missing, But this doesn't happen on larger devices like iPhone 6/6s. If i remove that text writer method then it works properly on all devices or if i reduce the video quality in 5s then also it works fine. How i can get video with audio in iPhone 5s with overlay text. Here is my code import Foundation import AVFoundation import

Segmentation fault when converting to Swift 4

£可爱£侵袭症+ 提交于 2021-01-28 02:46:19
问题 I am in the process of updating a project to iOS 11/Swift 4. I have updated to Swift 3.2 and have a project that builds with one warning: "Conversion to Swift 4 available". So I click the warning and start the migration assistant with the option "Minimize Inference" when asked about Swift 4 @objc Inference. The build fails quite quickly with this message: Command failed due to signal: Segmentation fault: 11 Stack trace: 0 swift 0x000000010afabdba PrintStackTraceSignalHandler(void*) + 42 1

Segmentation fault when converting to Swift 4

家住魔仙堡 提交于 2021-01-27 21:52:04
问题 I am in the process of updating a project to iOS 11/Swift 4. I have updated to Swift 3.2 and have a project that builds with one warning: "Conversion to Swift 4 available". So I click the warning and start the migration assistant with the option "Minimize Inference" when asked about Swift 4 @objc Inference. The build fails quite quickly with this message: Command failed due to signal: Segmentation fault: 11 Stack trace: 0 swift 0x000000010afabdba PrintStackTraceSignalHandler(void*) + 42 1

“ambiguous use” on generic method after migration to swift 4

若如初见. 提交于 2021-01-26 22:48:20
问题 I am trying to migrate my code from xcode 8.2 swift 3.0.2 to xcode 9 swift 4, and I have problem with this code: func test<T0, TRet>(_ fn: (T0) -> TRet) -> Void { print("foo1") print(T0.self) } func test<T0, T1, TRet>(_ fn: (T0, T1) -> TRet) -> Void { print("foo2") print(T0.self) print(T1.self) } let fn2 : (Int, Int) -> Int = { (x:Int, y:Int)->Int in return x+y } test(fn2) xcode 8.0.2, swift 3.0.2 results with: foo2 Int Int xcode 9, swift 4 results with: Playground execution failed: error:

“ambiguous use” on generic method after migration to swift 4

点点圈 提交于 2021-01-26 22:47:43
问题 I am trying to migrate my code from xcode 8.2 swift 3.0.2 to xcode 9 swift 4, and I have problem with this code: func test<T0, TRet>(_ fn: (T0) -> TRet) -> Void { print("foo1") print(T0.self) } func test<T0, T1, TRet>(_ fn: (T0, T1) -> TRet) -> Void { print("foo2") print(T0.self) print(T1.self) } let fn2 : (Int, Int) -> Int = { (x:Int, y:Int)->Int in return x+y } test(fn2) xcode 8.0.2, swift 3.0.2 results with: foo2 Int Int xcode 9, swift 4 results with: Playground execution failed: error:

Hot to decode JSON data that could and array or a single element in Swift?

自闭症网瘾萝莉.ら 提交于 2021-01-15 19:19:55
问题 I have a struct named Info which is decoded based on the data it receives. But sometimes, one of the values in data can either be a double or an array of double. How do I set up my struct for that? struct Info: Decodable { let author: String let title: String let tags: [Tags] let price: [Double] enum Tags: String, Decodable { case nonfiction case biography case fiction } } Based on the url, I either get price as a double { "author" : "Mark A", "title" : "The Great Deman", "tags" : [

Hot to decode JSON data that could and array or a single element in Swift?

╄→гoц情女王★ 提交于 2021-01-15 19:15:06
问题 I have a struct named Info which is decoded based on the data it receives. But sometimes, one of the values in data can either be a double or an array of double. How do I set up my struct for that? struct Info: Decodable { let author: String let title: String let tags: [Tags] let price: [Double] enum Tags: String, Decodable { case nonfiction case biography case fiction } } Based on the url, I either get price as a double { "author" : "Mark A", "title" : "The Great Deman", "tags" : [