vienvu89.github.io's People
vienvu89.github.io's Issues
Only allow int or double NSTextField
func controlTextDidChange(_ obj: Notification) {
if let textfield = obj.object as? NSTextField,
textfield == widthTextField || textfield == heightTextField {
var stringValue = textfield.stringValue
// First step : Only '1234567890.' - @Clifton Labrum solution
let charSet = NSCharacterSet(charactersIn: "1234567890.").inverted
let chars = stringValue.components(separatedBy: charSet)
stringValue = chars.joined()
// Second step : only one '.'
let comma = NSCharacterSet(charactersIn: ".")
let chuncks = stringValue.components(separatedBy: comma as CharacterSet)
switch chuncks.count {
case 0:
stringValue = ""
case 1:
stringValue = "\(chuncks[0])"
default:
stringValue = "\(chuncks[0]).\(chuncks[1])"
}
// replace string
textfield.stringValue = stringValue
}
}
UIStackView Bug
Sometimes you set items in UIStackView
and it doesn't work.
The bug is that hiding and showing views in a stack view is cumulative. Weird Apple bug. If you hide a view in a stack view twice, you need to show it twice to get it back.
http://www.openradar.me/25087688
To fix this issue you can use the following extension:
extension UIView {
var isHiddenInStackView: Bool {
get {
return isHidden
}
set {
if isHidden != newValue {
isHidden = newValue
}
}
}
}
and use:
stackView.subviews[someIndex].isHiddenInStackView = false
Convert date and NSCalendar
Universal link iOS
xcrun
supports opening URLs on iOS simulator as if they have been triggered by a user action.
So we can trigger it to test
xcrun simctl openurl booted https://www.example.com/chapter/123
or Schemes
xcrun simctl openurl booted โapp://example/chapter?id=2โ
Fix break constraint UIActionSheet
Add an extension and call it before present.
actionSheetController.pruneNegativeWidthConstraints()
extension UIAlertController {
func pruneNegativeWidthConstraints() {
for subView in self.view.subviews {
for constraint in subView.constraints where constraint.debugDescription.contains("width == - 16") {
subView.removeConstraint(constraint)
}
}
}
}
Test
Hi,
Reload Cell without anymation
Sometimes, the collectionView or tabelView has the dynamic cell's height can flickers while reloading cells individually.
We can use this code to avoid it:
UIView.performWithoutAnimation {
self.tableView.reloadRows(at: [indexPath], with: .none)
}
Dynamic change the App Icon
From iOS 10.3 Apple had added:
var supportsAlternateIcons: BoolA Boolean value indicating whether the app is allowed to change its icon.
var alternateIconName: String?The name of the icon being displayed for the app.
func setAlternateIconName(String?, completionHandler: ((Error?) -> Void)?)Changes the app's icon.
3 things will allow us to change the App Icon dynamic.
We can change the icon only if the value of the supportsAlternateIcons
property is true
.
We must declare our app's primary and alternate icons using the CFBundleIcons key of our app's Info.plist file.
We can check keys here https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102043
Reference: https://medium.com/ios-os-x-development/dynamically-change-the-app-icon-7d4bece820d2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.