uiviewcontroller

Keeping strong references with dynamic subviews in Swift

北战南征 提交于 2021-01-29 15:27:39
问题 I'm trying to implement a dynamic view composed UI elements sent by the backend, meaning it is not known beforehand how many and which UI elements will be displayed, the server sends JSON containing the types of fields that need to be rendered. So for example the sever sends: type: paragraph type: textfield Then I instantiate a class I have for each of those elements and add their views as subviews to my main dynamic view: class DynamicViewController: UIViewController { // array of subviews,

Can I preserve a modally presented view controller when setting the root view controller?

谁都会走 提交于 2021-01-29 08:33:05
问题 Let's say I have three view controllers. On the first one, I tap a button and present the second view controller modally. On the second one, I tap a button and store the presenting view controller (first), then set the third view controller as the root view controller. Finally, I have a button on the third view controller that grabs the stored controller and sets that as the root view controller. When I restore the first view controller, I find that its presentedViewController property is nil

iOS Swift subclassing ViewController initialized by xib (nib) file

走远了吗. 提交于 2021-01-27 06:08:26
问题 I have one base class MyViewController: UIViewController initialized by MyViewController.xib with some outlets. I only have set File Owner class in MyViewController.xib to MyViewController , no any init methods in MyViewController.swift (all inherited from UIViewController ), and following line works just as expected: let vc = MyViewController() view property is set, outlets is set. I wish to subclass MyViewController : SecondViewController: MyViewController { override init() { super.init() }

How do I use the Google Mobile Ads SDK in SwiftUI, or use the UIKit UIViewController within a SwiftUI view?

十年热恋 提交于 2021-01-20 22:01:40
问题 I have a SwiftUI view that I want to open a rewarded ad from the Google Mobile Ads SDK when I press a button. The instructions for loading the ads (https://developers.google.com/admob/ios/rewarded-ads#create_rewarded_ad) are in UIKit, and I'm struggling to use them in my SwiftUI app. Is there a way to load the ads using SwiftUI, or if I use UIKit, how do I integrate it into SwiftUI? This is the SwiftUI parent view: struct AdMenu: View { var body: some View { NavigationView { NavigationLink

How do I use the Google Mobile Ads SDK in SwiftUI, or use the UIKit UIViewController within a SwiftUI view?

冷暖自知 提交于 2021-01-20 21:58:59
问题 I have a SwiftUI view that I want to open a rewarded ad from the Google Mobile Ads SDK when I press a button. The instructions for loading the ads (https://developers.google.com/admob/ios/rewarded-ads#create_rewarded_ad) are in UIKit, and I'm struggling to use them in my SwiftUI app. Is there a way to load the ads using SwiftUI, or if I use UIKit, how do I integrate it into SwiftUI? This is the SwiftUI parent view: struct AdMenu: View { var body: some View { NavigationView { NavigationLink

Can I swizzle didSelectRowAtIndexPath: of UITableViewDelegate?

天涯浪子 提交于 2021-01-20 20:25:33
问题 The problem is this: I need to be able to get analytics on didSelectRowAtIndexPath throughout a big existing app with lots of tableViews. My first thought of this is doing method swizzling on didSelectRowAtIndexPath: but my app crashes with "unrecognized selector sent to instance" message depending on the stuff is accessed in the original didSelectRowAtIndexPath implementation. Here is how I try to achieve this in a UIViewController category: #import "UIViewController+Swizzle.h"

Can I swizzle didSelectRowAtIndexPath: of UITableViewDelegate?

怎甘沉沦 提交于 2021-01-20 20:25:30
问题 The problem is this: I need to be able to get analytics on didSelectRowAtIndexPath throughout a big existing app with lots of tableViews. My first thought of this is doing method swizzling on didSelectRowAtIndexPath: but my app crashes with "unrecognized selector sent to instance" message depending on the stuff is accessed in the original didSelectRowAtIndexPath implementation. Here is how I try to achieve this in a UIViewController category: #import "UIViewController+Swizzle.h"

Navigate from a ViewController to an another on didSelectRowAt programmatically

。_饼干妹妹 提交于 2020-12-15 07:07:24
问题 I have a UIViewController that contains a custom UITableView . The table has a custom UITableViewCell too. How to navigate from the first ViewController to an another when you select/click one of the rows? Note I have not used StoryBoard . Update This my code. Each one of the classes are external file. Let me know, if you need more code. class TestViewController: UIViewController, UITableViewDelegate { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white view

Button to instanciate ViewController is not working after hiding it

六眼飞鱼酱① 提交于 2020-12-06 06:51:47
问题 I have this very weird problem that I just found out... I have this button which is triggering this function : @objc func vergessenTapped() { let forgotPasswordVC = self.storyboard?.instantiateViewController(withIdentifier: "ForgotPasswordVC") as! ForgotPasswordVC forgotPasswordVC.email = self.emailTextField.text! self.present(forgotPasswordVC, animated: true, completion: nil) } I also have these function which hide / show the button above: // delegate Methode für eye-Button func

Button to instanciate ViewController is not working after hiding it

微笑、不失礼 提交于 2020-12-06 06:51:45
问题 I have this very weird problem that I just found out... I have this button which is triggering this function : @objc func vergessenTapped() { let forgotPasswordVC = self.storyboard?.instantiateViewController(withIdentifier: "ForgotPasswordVC") as! ForgotPasswordVC forgotPasswordVC.email = self.emailTextField.text! self.present(forgotPasswordVC, animated: true, completion: nil) } I also have these function which hide / show the button above: // delegate Methode für eye-Button func