uikit

iOS 13's presentationControllerDidDismiss() Not Called for Popover in Compact Environment

本小妞迷上赌 提交于 2020-06-16 02:19:07
问题 I am updating my app for iOS 13’s new “card-style” modal views. All has been working well using UIAdaptivePresentationControllerDelegate ’s presentationControllerDidAttemptToDismiss() and presentationControllerDidDismiss() functions. But, for views that have their .modalPresentationStyle set to .popover , presentationControllerDidDismiss() is not called when being presented in compact environments (such as a phone or iPad in split or slide-over). It’s called correctly when presented in a

Detect UI actions outside of main thread

放肆的年华 提交于 2020-06-09 08:25:06
问题 Note: This question is related to Warn on calls to UIKit from background threads but does not give an answer on two of the approaches below. I have a problem where the app screen blinks rapidly. I already had that problem in the past and it is due to updating the UI elements outside the main thread. Therefore I've put the following code in many places: assertMainThread(); which is: #define assertMainThread() NSAssert([NSThread isMainThread],@"Method called using a thread other than main!") Of

Somehow combine with search controller not working, any idea?

一曲冷凌霜 提交于 2020-06-01 07:35:27
问题 For some reason when I type in the search field it does not print out Xcode console the "str". What am I missing here? I followed his tutorial https://www.letsbuildthatapp.com/course_video?id=5232 import UIKit class SearchViewController: UIViewController { let searchController = UISearchController(searchResultsController: nil) var sink: Any? override func viewDidLoad() { super.viewDidLoad() setupSearchBarListener() navigationItem.searchController = searchController navigationController?

UILabel word wrap feature leaving space even when sufficient space available for the word

元气小坏坏 提交于 2020-05-24 05:07:16
问题 The problem coming even in storyboard. The UILabel is having following properties: numberOfLines = 0 lineBreakMode = .byWordWrapping Constraints: Leading & Trailing 26 points to superview; vertically center. Custom Font: Medium 17 Points. As you can see the fourth word cannot fit in the first line and hence a problem by creating bad layout. If I remove the last word the sentence fits in one line completely or say the fourth word. If adding a word after it moves both of them to next line which

How to wrap a UIBarButtonItem in a SwiftUI View?

我与影子孤独终老i 提交于 2020-05-24 05:03:19
问题 I'm trying to make a custom back button for the NavigationBar where I can put whatever text I like. My primary use case is that some of my views have no title, and when I click to a new view from that, the new view's back button in the navigation bar has no text, and only an arrow. It makes it hard for the user to tap this. I'm looking to set a custom back button that has the text "Back", but also has the back button icon, and works flawlessly with SwiftUI's animation mechanism. This is my

iOS13 UIAlertController with custom view & preferredStyle as actionsheet grayscale all colors

天大地大妈咪最大 提交于 2020-05-16 03:39:08
问题 I'm not exactly sure if it's a bug or a feature, but this code: let sheet = UIAlertController(customView: awesomeView, preferredStyle: .actionSheet) .... present(sheet, animated: true, completion: nil) in pre-iOS 13 gives me this result: and on iOS 13: I.e. all the customview's elements have been grayscale. I've tried to play with Tint/Text/Background/... colors of the buttons / label - in iOS 13 is does no effect at all. In older versions - UI is changing. The goal: to avoid the grayscale

UILabel with layer Corner radius AND shadow

情到浓时终转凉″ 提交于 2020-05-16 01:51:07
问题 i'm looking for a way to display a UILabel with layer.cornerRadius and layer.shadow . I figured out, that with label.clipsToBounds = true the cornerRadius will be set and with label.masksToBounds = false the shadow will be displayed With both only the shadow, without the cornerRadius will be displayed let label = UILabel() label.textAlignment = .center label.font = UIFont.systemFont(ofSize: 32, weight: .regular) label.textColor = .white label.clipsToBounds = true label.backgroundColor =

swift how to suggest user email in uitextfield as autocomplete

我只是一个虾纸丫 提交于 2020-05-14 01:58:57
问题 Rather than showing autocomplete words I would like to show the autocomplete of the user emails for example example@domain.com This happens if I go to https://www.superbru.com/beta/register.php in Safari I get my email address suggested to me in the autocomplete box. This is how I set up my textfield but still no email being suggested. private let emailTextField: UITextField = { let textField = UITextField() textField.height(equalTo: 45) textField.keyboardType = .emailAddress textField

How do I render a SwiftUI View that is not at the root hierarchy as a UIImage?

喜欢而已 提交于 2020-05-12 07:05:28
问题 Suppose I have a simple SwiftUI View that is not the ContentView such as this: struct Test: View { var body: some View { VStack { Text("Test 1") Text("Test 2") } } } How can I render this view as a UIImage? I've looked into solutions such as : extension UIView { func asImage() -> UIImage { let renderer = UIGraphicsImageRenderer(bounds: bounds) return renderer.image { rendererContext in layer.render(in: rendererContext.cgContext) } } } But it seems that solutions like that only work on UIView,

How do I render a SwiftUI View that is not at the root hierarchy as a UIImage?

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-12 07:04:58
问题 Suppose I have a simple SwiftUI View that is not the ContentView such as this: struct Test: View { var body: some View { VStack { Text("Test 1") Text("Test 2") } } } How can I render this view as a UIImage? I've looked into solutions such as : extension UIView { func asImage() -> UIImage { let renderer = UIGraphicsImageRenderer(bounds: bounds) return renderer.image { rendererContext in layer.render(in: rendererContext.cgContext) } } } But it seems that solutions like that only work on UIView,