9 Notes In January 2020
Happy new year
1. Git stash list / Git stash twice
I know just using git stash and git stash apply for one editing branch, so I need to modify two git branches with git stash list in a terminal.
$ git stash // note: first stash
$ git stash // note: second stash
$ git stash list // get all list stash, so first stash can be a last index
// example :
// first stash is index 1 (stash@{1})
// second stash is index 0 (stash@{0})
$ git stash apply //note: get back a last stash
$ git stash show stash@{1} //note: use "show" is check commit in that stash
$ git stash apply stash@{0} //note: get back second stash / a last stash
$ git stash apply stash@{1} //note: get back first stash
------------------------------------------
$ git stash clear // delete all stash
source: https://stackoverflow.com/questions/18063521/git-stash-twice2. After update image in LaunchScreen, when I launch the application missing images in Launch Screen on device.
In my case, I try to test in simulator and device, work on simulator but didn't work on device, so I got solution for my problem.
Turn off and then on again.
Seriously, restart the device — that’s what fixed it for me.
Here’s what didn’t work:
- Cleaning DerivedData
- Cleaning the project
- Uninstalling the app from the device
- Restarting Xcode
- Restarting the computer
Older observations:
Just like the others, it, in my case (edited):
- Works fine in the Simulator
- Didn't work on the devices iPhone 6/6S/X (IOS 12 / 13),
3. Font color UILabel not changing (set in programmatically) in IOS 12
Actually, I use IOS13 for test it's work for me but I try to test in ios 12 UILabel text color not chnging. list several methods that I tried :
- checklist label behavior, user interaction enabled, clip to bounds to be true in storyboard/ XIB file (not changing)
- change position call label text color from collection view cell to collection view data source (still not changing)
and finally, I found that problem because of my custom uicolor in assets.xcassets (color asset), make label text color when I set in label xib/ storyboard not can be changing, so my solution is change color in xib file and my code in swift file can changing.
4. iPhone X, 11 and UITableView Footer stick to bottom controller
So this I found a solution:
- set in xib/ storyboard : Select Table View > Size Inspector > Content Insets: Never
- set in programmatically in tableView
//from
self.tableView.contentInsetAdjustmentBehavior = .automatic
// to
self.tableView.contentInsetAdjustmentBehavior = .never
5. Extension URL to UIImage Thumbnail video .mp4
extension URL {
// Generate Thumbnails Video mp4
func getThumbnailImage() -> UIImage? {
let asset: AVAsset = AVAsset(url: self)
let imageGenerator = AVAssetImageGenerator(asset: asset)
do {
let thumbnailImage = try imageGenerator.copyCGImage(at: CMTimeMake(value: 1, timescale: 60), actualTime: nil)
return UIImage(cgImage: thumbnailImage)
} catch {
print(error)
}
return nil
}
}
6. Use Extention URL to UIImage
Import AVFoundation
Import UIKit
class ThumbnailsViewController: UIViewController {
@IBOutlet weak var imageview: UIImageView!
override func viewDidLoad() {
super.viewDIdLoad()
if let urlString = _story.url, let url = URL(string: urlString) {
if let thumbnailImage = url.getThumbnailImage() {
self.imageview.image = thumbnailImage
}
}
}
7. Use App Realm Browser get data from device IOS
In Xcode tab Windows -> Devices and simulators -> tab Devices -> in Installed apps select your app ex: 100DayOfCode -> app container action (icon gear ) -> Download Container
source: https://stackoverflow.com/a/28465803/8366535
8. Set Priority in programmatically
let constaintHighPrioriry = amountBubbleView.heightAnchor.constraint(equalToConstant: size.height - 24)
constaintHighPrioriry.priority = UILayoutPriority(1000)
constaintHighPrioriry.isActive = true
let constaintLowPrioriry = messageTextView.heightAnchor.constraint(equalToConstant: amountBubbleView.frame.height - frame.height)
constaintLowPrioriry.priority = UILayoutPriority(900)
constaintLowPrioriry.isActive = true
9. Set Priority in stackView
amountBubbleView.setContentHuggingPriority(UILayoutPriority(rawValue: 750), for: .vertical)
messageTextView.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .vertical)
// StackViewParent = .Vertical
let isGroupStackView = UIStackView(arrangedSubviews: [amountBubbleView, messageTextView])
isGroupStackView.axis = .vertical
isGroupStackView.alignment = .fill
isGroupStackView.distribution = .fill
isGroupStackView.spacing = 0
stackview.addArrangedSubview(isGroupStackView)
source: https://medium.com/@dineshk1389/content-hugging-and-compression-resistance-in-ios-35a0e8f19118
9 Notes In January 2020
Reviewed by Luffyselah
on
January 03, 2020
Rating: 5