Post

Replies

Boosts

Views

Activity

SwiftUI List Separator within NavigationView Problem
I'm note sure if this is well-known-issue or not but it is very odd. The problem can be reproduced with Apple's example code navigationBarItems(leading:trailing:) As you can see, list separators has extra leading space that looks like they are indented for some reason. I test above code with Playground, iPhone 13/15.3.1 they are the same. I did messing around the code and found that applying .navigationBarTitle(), .navigationBarItems() to List causes the problem. They must apply to each List item. Very odd though. This means almost all List sample code that wrapping with NavigationView are WRONG. Here is a fix I found. Although I'm not sure if I can call this is a bug but definitely either document or implementation is wrong. Could anyone explain this?
6
0
4.1k
Mar ’22
need introductory offer to intentionally lapsed users?
Hi, I have a quick question. I'm working on IAP which offers new users free trial first month. I read Apple guide line and one question came up that should I offer to intentionally lapsed users as well? Let's say an user is already subscribed and never used any other offers, noticed there is introductory offer, then the user cancels subscription and re-subscribe immediately, that way the user gets a free month subscription. Apple's document doesn't mention about lapsed time to become eligible to introductory offer there seems we need to offer the user free month. Is it correct? Thanks, -- JK
3
0
599
Oct ’23
Swift property initialization issue
Although my initial problem was solved on StackOverflow(Link Here), I'm still messing around this issue and can't find reasonable answer why property can't be overriden in init() if initial value is set. Here is entire code: import SwiftUI struct ContentView: View {     @State var bits: Int64 = 5     var body: some View {         Form {             Section {                 SectionView(title: "Section", withBits: $bits)             } header: {                 Text("Toggle")             }         }     } } struct SectionView: View {     let title: String     @Binding var bits: Int64     @State private var first: Bool = false     @State private var second: Bool = false     @State private var third: Bool = false     init(title: String, withBits: Binding<Int64>) {         self.title = title         self._bits = withBits // below three lines are completely ignored when they have initial value         self.first = withBits.wrappedValue & 1 == 1         self.second = withBits.wrappedValue & 2 == 2         self.third = withBits.wrappedValue & 4 == 4     }     var body: some View {         VStack {             HStack {                 Text(self.title)             }             HStack {                 Toggle("Toggle 1", isOn: self.$first)                     .onChange(of: self.first) { newValue in                         if newValue {                             self.bits |= 1                         }                         else {                             self.bits &= ~1                         }                     }             }             HStack {                 Toggle("Toggle 2", isOn: self.$second)                     .onChange(of: self.second) { newValue in                         if newValue {                             self.bits |= 2                         }                         else {                             self.bits &= ~2                         }                     }             }             HStack {                 Toggle("Toggle 3", isOn: self.$third)                     .onChange(of: self.third) { newValue in                         if newValue {                             self.bits |= 4                         }                         else {                             self.bits &= ~4                         }                     }             }         }         .onChange(of: self.bits) { newValue in             print("bits: \(bits)")         }     } } If I remove property initialization as below then works:     @State private var first: Bool     @State private var second: Bool     @State private var third: Bool Could anyone explain why above code won't work? I'm now kinda worry about my old code that I always set initial value to properties to avoid garbage in them so.
1
0
866
Feb ’22
Process image during camera preview
Hi, I'm trying to capture live image in camera preview but can't get image from preview layer. What I want to do is kinda similar to iOS 15 OCR mode in Photo app which processes image during camera preview, does not require user to take a shot nor start recording video, just process image in preview. I looked into docs and searched on net but could not find any useful info. What I tried was, save previewLayer and call previewLayer.draw(in: context) periodically. But the image drawn in the context is blank. Now I wonder if it is possible first of all. There might be some security issue there to restrict processing image in camera preview I guess, so I probably need to find other ways. Please enlighten me if any workaround. Thanks!
1
0
1.5k
Dec ’21