Post

Replies

Boosts

Views

Activity

Reply to IOS 15, javascript functions window.getSelection() or document.getSelection() not working
window.getSelection() actually works fine. The problem here is because when the focus is lost, then the selection is cleared as well. I forgot which version in ios i had this working before but now that i checked again under v16.1, it doesnt work. window.getSelection().rangeCount is always zero when i click a button to do some code with the text selection.
Topic: App & System Services SubTopic: Core OS Tags:
Jan ’24
Reply to Replace substring using regex in a string
Looks like my implementation seems off static func roundOff(_ val: String, _ decimalPlace: Int) -> String {     let decimalFormatter = createDecimalFormatter()     decimalFormatter.minimumFractionDigits = decimalPlace     decimalFormatter.maximumFractionDigits = decimalPlace     let bigDecimal = NSDecimalNumber(string: val)     return decimalFormatter.string(from: bigDecimal.rounding(accordingToBehavior: NSDecimalNumberHandler(roundingMode: .up, scale: Int16(decimalPlace), raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)))!   } static func cel2far(_ celsius: Double) -> String {     return roundOff(String(celsius * 9.0 / 5.0 + 32.0), 0)   }   static func far2cel(_ fahrenheit: Double) -> String {     return roundOff(String((fahrenheit - 32.0) * 0.5555555555555556), 0)   } LOL
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’23
Reply to Swift Chart has too many labels on x-axis. How to lessen them?
This is the chart data struct ChartData : Identifiable {   var id = UUID()   var date: String   var rainfallTo: Int   var tempMean: Int } and the chart code Chart(createChartData(city)) {               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value("Rainfall mm", $0.rainfallTo),                 series: .value("type", StringTool.localize("rainfall_mm"))               )               .foregroundStyle(by: .value("type", StringTool.localize("rainfall_mm")))               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value(StringTool.localize("temperature"), $0.tempMean),                 series: .value("type", StringTool.localize("temperature"))               )               .foregroundStyle(by: .value("type", StringTool.localize("temperature"))) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
Reply to touch events do not work in ipad air and pro
never mind. i added new code to check if device is running ios or max touch points is greater than 2.
Topic: Safari & Web SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to IOS 15, javascript functions window.getSelection() or document.getSelection() not working
window.getSelection() actually works fine. The problem here is because when the focus is lost, then the selection is cleared as well. I forgot which version in ios i had this working before but now that i checked again under v16.1, it doesnt work. window.getSelection().rangeCount is always zero when i click a button to do some code with the text selection.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to How To Loop Video In SwiftUI
@dave450 I decided to keep using VideoPlayer(player: AVPlayer) and add/remove an observer where after the video ends, it will play back to the first frame.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Incorrect rounding off result
I will close this thread. I finally came across a post. the rounding mode used is .plain. Though I do not understand but since it works i have no problem with it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Replace substring using regex in a string
Looks like my implementation seems off static func roundOff(_ val: String, _ decimalPlace: Int) -> String {     let decimalFormatter = createDecimalFormatter()     decimalFormatter.minimumFractionDigits = decimalPlace     decimalFormatter.maximumFractionDigits = decimalPlace     let bigDecimal = NSDecimalNumber(string: val)     return decimalFormatter.string(from: bigDecimal.rounding(accordingToBehavior: NSDecimalNumberHandler(roundingMode: .up, scale: Int16(decimalPlace), raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)))!   } static func cel2far(_ celsius: Double) -> String {     return roundOff(String(celsius * 9.0 / 5.0 + 32.0), 0)   }   static func far2cel(_ fahrenheit: Double) -> String {     return roundOff(String((fahrenheit - 32.0) * 0.5555555555555556), 0)   } LOL
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Build Input File Cannot Be Found .app
Baaah. Closing this. It seems I was reading an outdated documentation regarding a library and it is what messed up my project. I used the SPM's lib instead of Cocopods and it's all ok now.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Xcode 14 error Build input file cannot be found metadata-arm64
I do not understand the instructions change workspace setting > Build location > Custom & relative to workspace @chebby_ ? in the image there are 2 options. there is no option " Custom & relative to workspace"
Replies
Boosts
Views
Activity
Mar ’23
Reply to Push Notification With Background Task
i am also interested in this because this looks like how chat apps do it: fetching new data on certain intervals?
Replies
Boosts
Views
Activity
Mar ’23
Reply to BGTaskScheduler.shared.register() does not get called
Well, no matter what I do, it looks like background services are not supported by iOS. The .register just doesnt work. If i use .backgroundTask it does not meet my purpose since i want some kind of service that fetches data every 3am/pm, 6am/pm, 9am/pm, 12am/pm. I wondered how chat apps do this. Probably push notifications?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to BGTaskScheduler.shared.register() does not get called
Note: I am using this in SwiftUI
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to Callback Function As Parameter
Seems ill have to read up on closures. Thanks!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Why no "background mode" capability?
Mine also does not have. But you can manually add it. There is a "+ Capability" at the top left. Click it and search for Background Modes.
Replies
Boosts
Views
Activity
Feb ’23
Reply to Why Does Image Overlap In GridRow?
add .resizable() to Image is the solution.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Why Does Image Overlap In GridRow?
@claude31 i have not seen any replies, thought of tagging you if you do not mind since you help a lot. What do you think is wrong with the code?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Swift Chart has too many labels on x-axis. How to lessen them?
This is the chart data struct ChartData : Identifiable {   var id = UUID()   var date: String   var rainfallTo: Int   var tempMean: Int } and the chart code Chart(createChartData(city)) {               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value("Rainfall mm", $0.rainfallTo),                 series: .value("type", StringTool.localize("rainfall_mm"))               )               .foregroundStyle(by: .value("type", StringTool.localize("rainfall_mm")))               LineMark(                 x: .value(StringTool.localize("date"), $0.date),                 y: .value(StringTool.localize("temperature"), $0.tempMean),                 series: .value("type", StringTool.localize("temperature"))               )               .foregroundStyle(by: .value("type", StringTool.localize("temperature"))) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23