9 Notes for me in January Swift 4.2

1. Fixed if setting zoomed in iOS

if you have a problem io iOS (iPhone 6 and up )setting display zoomed and constraints,  not center, you must use auto constraint layout, maybe you can check in iPhone 5s for constraint in xib.


2. How to refer to a cell outside of cellForRowAtIndexPath

 use func for this action like :

func indexpathOutCellForRow() {
   let indexPath = IndexPath(row: 0, section: 0)
   let cell = tableView.cellForRow(at: indexPath) as! YourTabelCell
   cell.textField.text = "your text"
}

3.  Bottom tab bar custom in code

// bottom tabbar

self.tabBar.backgroundColor = UIColor.white  // default white
self.tabBar.tintColor = UIColor.red  // default blue

4. UICollectionView inside a UITableViewCell 

sometimes when using collectionView in tableview delegate and datasource must be in viewController.swift not in .xib or .nib file.

//must in view didload if condition -> collectionView inside tableView

self.tableView.datasource = self
self.tableView.delegate = self

5. Input text in textField Currency mode
-- in my code use like below :

@IBOutlet weak var inputTextField: UITextField!

// in view didload
self.inputTextField.onChange { value in
            self. inputTextField.text = Currency.currencyOnTextField(form: value)

        }

6. Tabbar Bottom without a title

// example home

        let home = HomeViewController()
        let homeImage: UIImage? = #imageLiteral(resourceName: "home").withRenderingMode(.alwaysTemplate)
        let homeSelected: UIImage? = #imageLiteral(resourceName: "homeSelected").withRenderingMode(.alwaysTemplate)
        home.tabBarItem = UITabBarItem(title: nil, image: homeImage, selectedImage: homeSelected)
        home.tabBarItem.imageInsets = UIEdgeInsets(top: 6, left: 0, bottom: -6, right: 0)
        home.tabBarItem.tag = 0

7. Stack View "How to set corner radius for UIStackView ?"

UIStackView just manages the position and size of its arranged views, the cornerRadius has no effect. Try to add a custom view below the stackView and set the cornerRadius of it.

8. Update "Carthage --platform ios" error in terminal

-- Could not find any available simulators for iOS
-> solution 1: move file Xcode.app to /Applications/Xcode.app
-> solution 2: Upgrading Carthage to 0.31.2 fixed the issue for me. ->   https://github.com/Carthage/Carthage/releases -> download Carthage.pkg8.18 MB and install

-- Unable to determine local Swift version

9. Error "dyld: Symbol not found: __T0SSMa" in Xcode 10

error:

dyld: Symbol not found: __T0BOWV
Referenced from: /private/var/containers/Bundle/Application/05F7236E- B1DB-4811-B9E2- 20BA82908ABD/****/Frameworks/EstimoteProximitySDK.framework/SwiftyJSON
Expected in: /private/var/containers/Bundle/Application/05F7236E-B1DB-4811-B9E2-20BA82908ABD/****/Frameworks/libswiftCore.dylib
in /private/var/containers/Bundle/Application/05F7236E-B1DB-4811-B9E2-20BA82908ABD/****/Frameworks/SwiftyJSON.framework/SwiftyJSON `

solution :

--1. Upgrade carthage version and update carthage

--2. example: in cartfile

before = github "SwiftyJSON/SwiftyJSON" "4.1.0"
After = github "SwiftyJSON/SwiftyJSON"

--3. carthage update --platform ios




No comments: