9 Notes in October 2019
1. Command-phasescriptexecution-failed-with-a-nonzero-exit-code
Go to keychain access -> right-click on login -> lock & unlock again -> clear Xcode project and make build again.
https://stackoverflow.com/a/53383349/8366535
2. Dismiss and forced portrait
3. Multi contact number in one contact name
4. Non-Active dark mode (IOS 13) in your app use "info.plist"
Set info.plist -> source code
Set info.plist -> property
5. Tuple and table view
6. Animation transition
7. Glow View
8. UISegmenControl change text color
9. Detect Dark Mode
support me: https://scripttes.blogspot.com/2018/10/contact-us.html
Go to keychain access -> right-click on login -> lock & unlock again -> clear Xcode project and make build again.
https://stackoverflow.com/a/53383349/8366535
2. Dismiss and forced portrait
// MARK: Change to portrait
UIDevice.current.setValue(Int(UIInterfaceOrientation.portrait.rawValue), forKey: "orientation")
// Mark: Always set portrait
(UIApplication.shared.delegate as! AppDelegate).restrictRotation = .portrait
// Dismiss navigation
dismiss()
3. Multi contact number in one contact name
import UIKit
import ContactsUI
class ContactPropertyViewController: UIViewController {
@IBOutlet weak var contactLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
title = "Multi Choice Contact"
self.contactLabel.text = "Contact number:"
}
@IBAction func handleContact(_ sender: UIButton) {
let contacVC = CNContactPickerViewController()
contacVC.delegate = self
contacVC.displayedPropertyKeys = [CNContactGivenNameKey, CNContactPhoneNumbersKey]
self.present(contacVC, animated: true, completion: nil)
}
}
extension ContactPropertyViewController: CNContactPickerDelegate {
// MARK: Delegate method CNContectPickerDelegate for select more than 1 phone number in one contact name
func contactPicker(_ picker: CNContactPickerViewController, didSelect contactProperty: CNContactProperty) {
if let phoneNo = contactProperty.value as? CNPhoneNumber{
print(phoneNo.stringValue)
self.contactLabel.text = " Contact No: \(phoneNo.stringValue)"
}else{
print("empty")
}
}
func contactPickerDidCancel(_ picker: CNContactPickerViewController) {
self.dismiss(animated: true, completion: nil)
}
}
4. Non-Active dark mode (IOS 13) in your app use "info.plist"
Set info.plist -> source code
<plist version="1.0">
<dict>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
</dict>
</plist>
Set info.plist -> property
5. Tuple and table view
import UIKit
class TupleDidDeselectViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var inventory: [(String, Int)] = [("yesterday", 4), ("belive", 2), ("one", 10)]
var idArr = [Int]()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID")
self.tableView.rowHeight = UITableView.automaticDimension
}
}
extension TupleDidDeselectViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return inventory.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath)
cell.textLabel?.text = inventory[indexPath.row].0
cell.accessoryType = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(indexPath.row)
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .checkmark
idArr.append(inventory[indexPath.row].1)
print(idArr)
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
print(indexPath.row)
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .none
if let index = idArr.index(of: inventory[indexPath.row].1) {
idArr.remove(at: index)
print(idArr)
}
if let index = idArr.index(of: inventory[indexPath.row].1) {
print(index)
}
}
}
6. Animation transition
//MARK: Animation transision
func animateTransisionView() {
UIView.transition(with: view, duration: 0.4, options: .curveEaseInOut, animations: {
self.itemStackView.isHidden = false
self.goBotton.isHidden = false
})
}
7. Glow View
func glowView(active vw_active: UIView, none vw_none: UIView) {
//MARK: active
vw_active.clipsToBounds = false
vw_active.layer.shadowColor = UIColor.darkGray.cgColor
vw_active.layer.shadowOffset = .zero
vw_active.layer.shadowOpacity = 0.9
vw_active.layer.shadowRadius = 5
vw_active.layer.shadowPath = UIBezierPath(roundedRect: vw_active.bounds, cornerRadius: 14).cgPath
//MARK: none active
vw_none.layer.shadowRadius = 0
vw_none.layer.shadowColor = UIColor.clear.cgColor
}
8. UISegmenControl change text color
UISegmentedControl.appearance().setTitleTextAttributes(
[NSAttributedString.Key.foregroundColor: UIColor.darkGray], for: .normal)
9. Detect Dark Mode
if traitCollection.userInterfaceStyle == .light {
print("Light mode")
} else {
print("Dark mode")
}
support me: https://scripttes.blogspot.com/2018/10/contact-us.html
No comments: