Auto Layout

RSS for tag

Create a user interface that dynamically responds to changes in the available screen space using Auto Layout.

Posts under Auto Layout tag

15 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

[iOS18][RTL][Crash]
Hi all, Firebase statistics show that some crashes seem to occur suddenly. Can you give me some suggestions? Users also meet the following requirements: iOS18 and above RTL language From the stack frame, the crash occurred in the transition animation project, but I did not reproduce this stack frame A very small number of users can experience it twice The crashed page is relatively complex, and it is a mixture of auto-layout and frame I retrieved some other articles, but they don’t seem to be the same problem https://developer.apple.com/forums/thread/693118 https://stackoverflow.com/questions/56027014/collectionview-crashing-in-nsisengine-after-a-few-scrolls Thank you for reading, looking forward to your reply ;) CoreAutoLayout: _engineVar_rawRemove
0
0
226
Oct ’24
Xcode16RC present PHPickerViewController layout error & cell non-Interactive.
After upgrading to Xcode16RC, in an old project based on ObjC, I directly used the following controller code in AppDelegate: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIButton *b = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 44, 44)]; [b setTitle:@"title" forState:UIControlStateNormal]; [self.view addSubview:b]; [b addTarget:self action:@selector(onB:) forControlEvents:UIControlEventTouchUpInside]; } - (IBAction)onB:(id)sender{ PHPickerConfiguration *config = [[PHPickerConfiguration alloc]initWithPhotoLibrary:PHPhotoLibrary.sharedPhotoLibrary]; config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent; config.selectionLimit = 1; config.filter = nil; PHPickerViewController *picker = [[PHPickerViewController alloc]initWithConfiguration:config]; picker.modalPresentationStyle = UIModalPresentationFullScreen; picker.delegate = self; [self presentViewController:picker animated:true completion:nil]; } - (void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results{ } Environment: Simulator iPhone 15 Pro (iOS18) Before this version (iOS17.4), clicking the button to pop up the system photo picker interface was normal (the top boundary was within the SafeAreaGuide area), but now the top boundary of the interface aligns directly to the top of the window, and clicking the photo cell is unresponsive. If I create a new Target, using the same codes, the photo picker page does not have the above problem. Therefore, I suspect it may be due to the old project’s .proj file’s info.plist, buildSetting, or buildPhase lacking some default configuration key value required by the new version, (My project was built years ago may be from iOS13 or earlier ) but I cannot confirm the final cause. iOS18.0 has the additional messages: objc[79039]: Class UIAccessibilityLoaderWebShared is implemented in both /Library/Developer/CoreSimulator/Volumes/iOS_22A3351/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/AccessibilityBundles/WebCore.axbundle/WebCore (0x198028328) and /Library/Developer/CoreSimulator/Volumes/iOS_22A3351/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/AccessibilityBundles/WebKit.axbundle/WebKit (0x1980fc398). One of the two will be used. Which one is undefined. AX Safe category class 'SLHighlightDisambiguationPillViewAccessibility' was not found! Has anyone encountered the same issue as me?
2
2
618
Sep ’24
Spring Animations with Constraints don't behave properly
Repo is here Visual Description is here: Basically the red view should never be inside the blue view. The red view has a fixed aspect ratio. The blue view initially has an aspect ratio different from the red view and is animated to have the same aspect ratio. The red view is constrained inside the blue view as follows: let ac = brokenView.widthAnchor.constraint(equalTo: brokenView.heightAnchor, multiplier: 9/16) let xc = brokenView.centerXAnchor.constraint(equalTo: animView.centerXAnchor) let yc = brokenView.centerYAnchor.constraint(equalTo: animView.centerYAnchor) let widthC = brokenView.widthAnchor.constraint(equalTo: animView.widthAnchor) widthC.priority = .defaultLow let gewc = brokenView.widthAnchor.constraint(greaterThanOrEqualTo: animView.widthAnchor) let geHC = brokenView.heightAnchor.constraint(greaterThanOrEqualTo: animView.heightAnchor) geHC.priority = .required So the red view should start at equal width, but prioritize always been taller and wider than the blue view while staying centered and keeping a fixed aspect ratio. As you can see in the visual description it is not priortizing being taller. Any suggestions on how to fix, work around, or otherwise get past this would be appreciated. Really trying to avoid manually doing a spring animation with keyframes and an assload of math. I have filed a bug on feedback assistant, but figured someone here might have experience//know how. Thanks
0
0
419
Jun ’24
(Swift) TextField border contained in a view remains visible even when the view is fully overlapped by another view.
I have a ZStack that contains a VStack with 2 views (view1 and view2) and a third view (view3). So, is either that view1 and View1 are visible, or view3 is visible. This is the relevant code: ZStack { VStack { view1() View2() } if showView3 View3() } view1 and view2 are 400px in width and 200px in height, while view3 is 400 x 400 px, so that it completely overwrite view1/view2 when visible. The problem I'm trying to solve is that the border of a TextField placed in view1 is visible when showView3 is true, what should not be happening (possible glitch in swift?). To show the problem, I prepared a code sample, which shows that when view3 is active, it completely overwrites view1/view2, but still, the border of the TextField remains visible. (See screenshot below) struct TestZStackView: View { @State private var showView3 = false var body: some View { ZStack { VStack { Toggle("view3", isOn: $showView3) View1() .frame(width: 400, height: 200) .background(Color.red) .zIndex(1) View2() .frame(width: 400, height: 200) .background(Color.green) .zIndex(1) } if showView3 { View3() .frame(width: 400, height: 400) .background(Color.blue) .zIndex(2) } } } } struct View1: View { var body: some View { TextField("Enter text", text: .constant("")) .padding() .cornerRadius(5) .textFieldStyle(RoundedBorderTextFieldStyle()) .zIndex(1) } } struct View2: View { var body: some View { Color.clear } } struct View3: View { var body: some View { Color.black // (Ensure no transparency) } } zIndex() are not required, I just placed them to see if the problem get solved, but it may no difference. BTW, in the code above, the visible border disappears if the view is minimized, but that is not the case in the real app I'm working on. In the screenshots attached, it can be seen how the TextField border remains visible when view3 is active ("https://developer.apple.com/forums/content/attachment/d0e75f25-d36e-4361-af64-54252d1f2a98" "title=Screenshot 2024-05-24 at 10.06.03 PM.png;width=800;height=632")
0
0
473
May ’24
(Swift) TextField border contained in a view remains visible even when the view is fully overlapped by another view.
I have a ZStack that contains a VStack with 2 views (view1 and view2) and a third view (view3). So, is either that view1 and View1 are visible, or view3 is visible. This is the relevant code: ZStack { VStack { view1() View2() } if showView3 View3() } view1 and view2 are 400px in width and 200px in height, while view3 is 400 x 400 px, so that it completely overwrite view1/view2 when visible. The problem I'm trying to solve is that the border of a TextField placed in view1 is visible when showView3 is true, what should not be happening (possible glitch in swift?). To show the problem, I prepared a code sample, which shows that when view3 is active, it completely overwrites view1/view2, but still, the border of the TextField remains visible. (See screenshot below) struct TestZStackView: View { @State private var showView3 = false var body: some View { ZStack { VStack { Toggle("view3", isOn: $showView3) View1() .frame(width: 400, height: 200) .background(Color.red) .zIndex(1) View2() .frame(width: 400, height: 200) .background(Color.green) .zIndex(1) } if showView3 { View3() .frame(width: 400, height: 400) .background(Color.blue) .zIndex(2) } } } } struct View1: View { var body: some View { TextField("Enter text", text: .constant("")) .padding() .cornerRadius(5) .textFieldStyle(RoundedBorderTextFieldStyle()) .zIndex(1) } } struct View2: View { var body: some View { Color.clear } } struct View3: View { var body: some View { Color.black // (Ensure no transparency) } } zIndex() are not required, I just placed them to see if the problem get solved, but it may no difference. BTW, in the code above, the visible border disappears if the view is minimized, but that is not the case in the real app I'm working on. In the screenshots attached, it can be seen how the TextField border remains visible when view3 is active ("https://developer.apple.com/forums/content/attachment/d0e75f25-d36e-4361-af64-54252d1f2a98" "title=Screenshot 2024-05-24 at 10.06.03 PM.png;width=800;height=632")
0
0
526
May ’24
Replicate Microsoft's UWP to Apple OS
Microsoft did a very good job with UWP, when you build app for Windows Phone, those app automatically scales to big screen (horizontal oriented devices) Tablet, PC, Xbox. Kind of similar to website that have responsive UI. Eitherway, Apple needs to do something similar... there is no reason why phone apps are so small on my iMac. Even if it is already supported, Apple needs to encourage developers to implement it.
0
0
416
Apr ’24
Non-main thread crash _AssertAutoLayoutOnAllowedThreadsOnly
This crash happens online and cannot be tested and reproduced. I need help. Thank you very much. Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x000000018b4190d0 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: SIGNAL 5 Trace/BPT trap: 5 Terminating Process: exc handler [338] Triggered by Thread: 7 Last Exception Backtrace: 0 CoreFoundation 0x180cd7c60 __exceptionPreprocess + 216 (NSException.m:200) 1 libobjc.A.dylib 0x198507ee4 objc_exception_throw + 56 (objc-exception.mm:565) 2 CoreAutoLayout 0x1987cb000 _AssertAutoLayoutOnAllowedThreadsOnly + 412 (NSISEngine.m:0) 3 CoreAutoLayout 0x1987cdb7c -[NSISEngine withBehaviors:performModifications:] + 32 (NSISEngine.m:1975) 4 UIKitCore 0x1831262fc -[UIView _resetLayoutEngineHostConstraints] + 80 (NSLayoutConstraint_UIKitAdditions.m:1426) 5 UIKitCore 0x1830fc0c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2376 (UIView.m:18416) 6 QuartzCore 0x18477c520 CA::Layer::layout_if_needed(CA::Transaction*) + 528 (CALayer.mm:10118) 7 QuartzCore 0x18476f294 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 132 (CALayer.mm:2480) 8 QuartzCore 0x184782cc8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 464 (CAContextInternal.mm:2612) 9 QuartzCore 0x18478b79c CA::Transaction::commit() + 708 (CATransactionInternal.mm:449) 10 QuartzCore 0x1847dfe04 CA::Transaction::release_thread(void*) + 224 (CATransactionInternal.mm:651) 11 libsystem_pthread.dylib 0x1dc052d90 _pthread_tsd_cleanup + 520 (pthread_tsd.c:388) 12 libsystem_pthread.dylib 0x1dc055c08 _pthread_exit + 80 (pthread.c:1717) 13 libsystem_pthread.dylib 0x1dc05124c _pthread_wqthread_exit + 100 (pthread.c:2559) 14 libsystem_pthread.dylib 0x1dc050e88 _pthread_wqthread + 420 (pthread.c:2593) 15 libsystem_pthread.dylib 0x1dc05092c start_wqthread + 8 (:-1)
1
0
534
Apr ’24
AI text format style in Pages and Numbers
Hi can you add new feature in Pages and Numbers using Ai to apply style from PDF or template to documents, so ai arrange footers and headers and fonts , pages breaks , pages numbers, like one in PDF or templates , so we can auto format documents to desired look standard, also for Numbers. So we can on raw text upload pdf of another documents or report and get documents in that style for export to pdf or print Best regards,
1
0
584
Apr ’24
App crash giving reason Terminating app due to uncaught exception
giving this every time *** Assertion failure in void _engineVar_rawRemove(NSISEngineVar)(), NSISEngine_EngineVar.h:181 2024-03-21 16:29:48.644662+0530 Yanabea[6857:1455909] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Not possible to remove variable: 922: <unknown var (bug!) with engine as delegate:0x282bd7d80>{id: 10158} colIndex:103 from engine <NSISEngine: 0x1500b4350>{ delegate:0x14bdc8ca0 EngineVars: . . . . 78 -> 2 79 -> 1 80 -> 1 }.' terminating with uncaught exception of type NSException and rest thousands of line of logs that I am tried to attached in the attachment but it is not supporting.
0
1
608
Mar ’24
iOS size classes like Regular, compact, Any
I am new to using iOS Objective-C size classes like Regular, compact, Any. I found that Compact size classes are anything less than ~640 pts and Regular size classes are anything larger than ~640 pts . Is that correct for both iphone and ipad? How can I use size class to make an image full screen on all the iphone and ipad devices and on any orientation? How many images will I need? Any help and insight is greatly appreciated!
0
0
847
Mar ’24
Sizing DTAttributedTextContentView based on its attributedString
I am trying to self size DTAttributedTextContentView inside the collection cell based on its attributed text. The problem I face is that when I set attributedTextContentView width constraints like so: attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260) it applies the whole constant width (in this case 260) to the textContentView, even if attributedString length is smaller than the width, leaving some extra space: My question is, how to size the frame of DTAttributedTextContentView so that it just encloses the text that it contains? Initially I used basic UITextView, but the scrolling of cells through collection view is not that smooth when there are multiple cells, and also it gives possibility to easy access the last line of the text inside, which I need for my app, so I would like to stick to DTAttributedTextContentView. Here is the sample code for testing: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() configureCollectionView() } // MARK: - Collection view setup let collectionView: UICollectionView = { let layout = UICollectionViewCompositionalLayout { (section, environment) -> NSCollectionLayoutSection? in let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(10)) let item = NSCollectionLayoutItem(layoutSize: itemSize) let group = NSCollectionLayoutGroup.vertical(layoutSize: itemSize, subitems: [item]) let section = NSCollectionLayoutSection(group: group) section.interGroupSpacing = 5 return section } layout.configuration.scrollDirection = .vertical let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.register(ConversationCollectionViewCell.self, forCellWithReuseIdentifier: "ConversationCell") return collectionView }() private func configureCollectionView() { collectionView.dataSource = self collectionView.backgroundColor = .brown view.addSubview(collectionView) collectionView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), collectionView.topAnchor.constraint(equalTo: view.topAnchor), collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor) ]) } } // MARK: - Collection Data Source extension ViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 10 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ConversationCell", for: indexPath) as! ConversationCollectionViewCell return cell } } // MARK: - Collection View Custon Cell final class ConversationCollectionViewCell: UICollectionViewCell, DTAttributedTextContentViewDelegate { var mainCellContainerView = UIView() var attributedTextContentView = DTAttributedTextContentView() //MARK: - LIFECYCLE override init(frame: CGRect) { super.init(frame: frame) setupmainCellContainerView() setupAttributedTextContentView() layoutIfNeeded() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } // MARK: - UI STEUP private func setupmainCellContainerView() { contentView.addSubview(mainCellContainerView) mainCellContainerView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ mainCellContainerView.topAnchor.constraint(equalTo: contentView.topAnchor), mainCellContainerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), mainCellContainerView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), mainCellContainerView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), ]) } private func setupAttributedTextContentView() { mainCellContainerView.addSubview(attributedTextContentView) attributedTextContentView.backgroundColor = .systemIndigo attributedTextContentView.delegate = self attributedTextContentView.sizeToFit() let attributedString = NSAttributedString(string: "Simple message for testing purpose @", attributes: [ .font: UIFont(name: "HelveticaNeue", size: 17), .foregroundColor: UIColor.white, .paragraphStyle: { let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .left paragraphStyle.lineBreakMode = .byWordWrapping return paragraphStyle }() ]) attributedTextContentView.attributedString = attributedString attributedTextContentView.contentMode = .redraw attributedTextContentView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ attributedTextContentView.widthAnchor.constraint(lessThanOrEqualToConstant: 260), attributedTextContentView.topAnchor.constraint(equalTo: mainCellContainerView.topAnchor), attributedTextContentView.bottomAnchor.constraint(equalTo: mainCellContainerView.bottomAnchor), ]) } }
1
0
517
Feb ’24
Custom view animates from bottom - up at first, but not afterwards.
I have this ToastView that will animate by expanding the height from the top of the screen. All the components are created programmatically. This is the code: final class ToastView: UIView { private static let instance = createContainer() private let labelHeightOffset: CGFloat = 32 private let messageLabel: UILabel = { let label = UILabel() label.textAlignment = .center label.numberOfLines = 0 return label }() private var heightConstraint: NSLayoutConstraint! static func show(message: String) { let keyWindow = UIWindow.getKeyWindow() //extension to get the kley window show(on: keyWindow, message: message) } private static func show(on parentView: UIView? = nil, message: String) { guard let parentView = parentView ?? UIViewController.getTopViewController()?.view, instance.superview == nil, let toast = toast else { return } parentView.addSubview(instance, method: .fill) toast.messageLabel.text = message toast.messageLabel.textColor = .red toast.messageLabel.textAlignment = .center toast.messageLabel.sizeToFit() toast.show(for: 3) } private func show(for duration: TimeInterval = 0) { isHidden = false layoutIfNeeded() UIView.animate(withDuration: 0.4, animations: { let labelLineHeight = self.messageLabel.getRect(maxLine: 3).size.height //getRect is an extension func to get the rect based on the content of the label let lineSpaces = CGFloat((self.messageLabel.getLineNumber() - 1) * 2) //getLineNumber is an extension func to get the total number of lines based on the content //Get the height by the content of the label self.heightConstraint.constant = self.labelLineHeight + self.labelHeightOffset + lineSpaces self.setNeedsUpdateConstraints() self.superview?.layoutIfNeeded() }, completion: { _ in self.hide(delay: duration) }) } private func hide(delay: TimeInterval = 0) { UIView.animate(withDuration: 0.4, delay: delay, animations: { self.heightConstraint.constant = 0 self.setNeedsUpdateConstraints() self.superview?.layoutIfNeeded() }, completion: { _ in self.isHidden = true self.messageLabel.text = nil ToastView.instance.removeFromSuperview() }) } } private extension ToastView { static var toast: ToastView? { return instance.subviews[0] as? ToastView } static func createContainer() -> UIView { let container = UIView(frame: .zero) container.backgroundColor = .clear let toast = ToastView(frame: .zero) toast.backgroundColor = .white toast.addCorner(radius: 8) container.addSubview(toast) toast.layoutMessageLabel() toast.layoutToast() return container } func layoutMessageLabel() { addSubview(messageLabel) messageLabel.center = center messageLabel.translatesAutoresizingMaskIntoConstraints = false let constraints = [ centerYAnchor.constraint(equalTo: messageLabel.centerYAnchor), leftAnchor.constraint(equalTo: messageLabel.leftAnchor, constant: 16), rightAnchor.constraint(equalTo: messageLabel.rightAnchor, constant: 16) ] NSLayoutConstraint.activate(constraints) messageLabel.setNeedsUpdateConstraints() layoutIfNeeded() } func layoutToast() { translatesAutoresizingMaskIntoConstraints = false let topConstants: CGFloat = UIWindow.getKeyWindow()?.safeAreaInsets.top ?? 0 + 16 let topConstraint = topAnchor.constraint(equalTo: superview!.topAnchor, constant: topConstants) heightConstraint = heightAnchor.constraint(equalToConstant: 0) let constraints = [ topConstraint, heightConstraint!, leftAnchor.constraint(equalTo: superview!.leftAnchor, constant: 16), superview!.rightAnchor.constraint(equalTo: rightAnchor, constant: 16) ] NSLayoutConstraint.activate(constraints) setNeedsUpdateConstraints() superview!.layoutIfNeeded() } } The code is working fine EXCEPT for the first time it appears. It always animates from the bottom of the screen and rising above ot the top. But if you'll have a look at the code, I only animte the heightConstraint's constant value. Why is this happening? Can you help me fix this? thanks.
1
0
966
Dec ’23
Auto Layout Constraint Conflict in SwiftUI When Tapping TextField
I am developing an iOS app using SwiftUI and have encountered an Auto Layout constraint conflict issue that appears when tapping on a TextField within a LoginView. I've tried several troubleshooting steps but haven't been able to resolve it. Error Message: Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x6000021298b0 'accessoryView.bottom' _UIRemoteKeyboardPlaceholderView:0x10460dd10.bottom == _UIKBCompatInputView:0x1059220e0.top (active)>", "<NSLayoutConstraint:0x60000217a620 'assistantHeight' SystemInputAssistantView.height == 45 (active, names: SystemInputAssistantView:0x10591ce60 )>", "<NSLayoutConstraint:0x60000217d090 'assistantView.bottom' SystemInputAssistantView.bottom == _UIKBCompatInputView:0x1059220e0.top (active, names: SystemInputAssistantView:0x10591ce60 )>", "<NSLayoutConstraint:0x60000217d040 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x10460dd10]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x10591ce60 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x60000217d040 'assistantView.top' V:[_UIRemoteKeyboardPlaceholderView:0x10460dd10]-(0)-[SystemInputAssistantView] (active, names: SystemInputAssistantView:0x10591ce60 )> This error appears in the console when I click on the TextField in my LoginView while running the code on a simulation. The app doesn't crash, but the console indicates there is a constraint conflict related to the keyboard. Here's my LoginView: struct LoginView: View { @StateObject var viewModel = LoginViewModel() var body: some View { NavigationStack { VStack { Spacer() Image("logo") .resizable() .scaledToFit() .frame(width: 150, height: 100) VStack { TextField("Enter your email", text: $viewModel.email) .autocapitalization(/*@START_MENU_TOKEN@*/.none/*@END_MENU_TOKEN@*/) .modifier(TextFieldModifier()) SecureField("Enter your password", text: $viewModel.password) .modifier(TextFieldModifier()) } Button { print("Show forgot password") } label: { Text("Forgot Password") .font(.footnote) .fontWeight(.semibold) .padding(.top) .padding(.trailing, 20) } .frame(maxWidth: .infinity, alignment: .trailing) Button { Task { try await viewModel.signIn() } } label: { Text("Login") .font(.subheadline) .fontWeight(.semibold) .foregroundColor(.white) .frame(width: 360, height: 44) .background(Color(.black)) .cornerRadius(8) } .padding(.vertical) HStack { Rectangle() .frame(width: (UIScreen.main.bounds.width / 2) - 40, height: 0.5) Text("OR") .font(.footnote) .fontWeight(.semibold) .foregroundColor(.gray) Rectangle() .frame(width: (UIScreen.main.bounds.width / 2) - 40, height: 0.5) } .foregroundColor(.gray) HStack { Image("facebook_logo") .resizable() .frame(width: 20, height: 20) Text("Continue with Facebook") .font(.footnote) .fontWeight(.semibold) .foregroundColor(Color(.systemBlue)) } .padding(.top, 8) Spacer() Divider() NavigationLink { AddEmailView() .navigationBarBackButtonHidden(true) } label: { HStack (spacing: 3) { Text("Don't have an account?") Text("Sign Up") .fontWeight(.semibold) } .font(.footnote) } .padding(.vertical, 16) } } } } #Preview { LoginView() } And my TextFieldModifier: struct TextFieldModifier: ViewModifier { func body(content: Content) ->some View { content .font(.subheadline) .padding(12) .background(Color(.systemGray6)) .cornerRadius(10) .padding(.horizontal, 24) .padding(.top) } } Attempts to Resolve: I've checked the TextFieldModifier for any potential issues but it seems standard. I've tried simplifying the view by removing other elements, but the issue persists. The issue seems to occur regardless of the simulator device or iOS version I use. Questions: What could be causing this Auto Layout constraint conflict in a SwiftUI app? Are there any known issues with SwiftUI's TextField and keyboard interactions that might lead to such constraints issues? Any suggestions on how to debug or resolve this constraint conflict?
3
3
2.0k
Jul ’24