uikit

UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController

﹥>﹥吖頭↗ 提交于 2020-02-02 09:47:04
问题 I'm new to Swift and I'm getting this Error. I don't get it because I don't use any type of alert in my code. Here is my ViewController: import UIKit import WebKit class ViewController: UIViewController{ @IBOutlet weak var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "https://www.google.com/maps")! webView.load(URLRequest(url: url)) } } I only want to use WKWebView in my app and use the location. I already added

How can I add a boolean value to a NSDictionary?

霸气de小男生 提交于 2020-01-30 13:52:22
问题 Well, for integers I would use NSNumber . But YES and NO aren't objects, I guess. A.f.a.i.k. I can only add objects to an NSDictionary , right? I couldn't find any wrapper class for booleans. Is there any? 回答1: You use NSNumber. It has init... and number... methods that take booleans, just as it does integers and so on. From the NSNumber class reference: // Creates and returns an NSNumber object containing a // given value, treating it as a BOOL. + (NSNumber *)numberWithBool:(BOOL)value and:

TouchMoved and wrong screen range? or Bug in iOS?

一个人想着一个人 提交于 2020-01-30 10:55:08
问题 I found interesting bug in iOS, but trying to belive that i'm wrong. You have to do 2 things: 1) Create single-view template for iOS 2) Write small function in ViewController.m : - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; CGPoint point = [touch locationInView:[touch view]]; NSLog(@"%@", NSStringFromCGPoint(point)); }// so u can detect points of your touch So if u try to move finger on display from screen's top to bottom (portrait

How to check current font size of UILabel?

一曲冷凌霜 提交于 2020-01-30 08:08:10
问题 I have 3 UILabels and I want to set same (the smallest one from all of 3 possibilities) font for all of them. What is the problem? I don't know how to check the current font - each of UILabels use Autoshrink with minimal font scale and lines amount equaled to 0. The text of UILabels is set in ViewDidLoad() method (there are many combinations of possible label texts). I tried to get the current font size with UILabel.font.pointSize property (called in viewDidAppear() method) and than compare

Finish editing UITextField on back button tap

半城伤御伤魂 提交于 2020-01-29 19:06:01
问题 I have 2 controllers inside NavigationController. First pushes the second one to the stack and user can interact with the text field there. Then (in one scenario) user will tap on back button to be taken to the previous screen. Assuming that loading of second one is 'heavy', so I will be keeping only one instance of it once it is needed. Expected: I would like to have keyboard hidden once back button is pressed. Actual: First responder keeps being restored when I go back to the second for the

How do I get a UIButton to size itself in a UIStackView?

假装没事ソ 提交于 2020-01-26 04:44:26
问题 I'm creating a stack view as part of a UIControl subclass that successfully lays out n buttons. The problem is, if I inspect the frame of any button, even though I can see their text, it says their width and height are 0. final class MySegmentedControl: UIControl { private var stackView: UIStackView? private var selection: UIView? = nil var selectedSegmentIndex: Int = 0 var items: [String] = [] private var segmentCount: CGFloat { CGFloat(items.count) } private var segmentWidth: CGFloat {

How do I change text attributes for a navigation bar title in SwiftUI?

只谈情不闲聊 提交于 2020-01-25 09:24:45
问题 lately, I've been playing around with the new SwiftUI framework. I do have a basic understanding of how the framework works but I cannot figure out a way to change title attributes for a navigation bar. I am using the latest Xcode 11 beta 5 and the corresponding swift/swiftUI version I already tried a few things. First thing I tried was to just add modifiers to a Text, but somehow SwiftUI seems to ignore modifiers in a navigation bar environment. The second thing I tried was to change the

Crash when open containing app from today extension

非 Y 不嫁゛ 提交于 2020-01-25 04:40:10
问题 I created today extension and add a button to open containing app. Inside extension view controller: @IBAction func pressed() { extensionContext?.openURL(NSURL(string:"myApp://")!, completionHandler: nil) } So, I also add URL Scheme to containing app plist: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>myApp</string> </array> </dict> </array> Widget works fine, but when I try to press widget my app crashes inside containing app AppDelegate.swift.

iOS, native blur view effects available from iOS9+?

一个人想着一个人 提交于 2020-01-24 20:19:08
问题 I'm trying to show a view / popup (a dialog), however I need a blur effect in the background and support iOS 9+. Are they blur operations provided natively in UIKit which will support rotation? I'm concerned that the blur effect will work off a screenshot and once I've shown my dialog and the screen rotates it won't be possible to add a blur effect to the screenshot image. Perhaps there are other options. 回答1: UIKIt has a UIVisualEffectView to add the beautiful blur effects from the object

UITextView stange animation glitch on paste action (iOS11)

落花浮王杯 提交于 2020-01-24 10:34:05
问题 I'm facing a very strange bug. When I paste anything inside UITextView , I receive a surprising glitch of animation. To reproduce it I've just created a black .xcodeproj , added UITextView to ViewController via storyboard and ran the application. The only similiar problem I've found is https://twitter.com/twostraws/status/972914692195790849 And it says that it's a bug of UIKit in iOS11. But there lot of applications on my iPhone with UITextview that works correctly on iOS11. You can see the