Posts

Post marked as solved
7 Replies
class PresentedBaseClass : UIView{ override init(frame: CGRect){ super.init(frame: frame) setupSubviews() } func setupSubviews(){ self.translatesAutoresizingMaskIntoConstraints = false // This is the problematic line // ... some code to create subviews setupConstraints() } func setupConstraints(){ NSLayoutConstraint.activate([ // Adding the two lines of code below will correct the problem, although // it is probably better to remove the problematic line //self.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width) //self.heightAnchor.constraint(equalToConstant: UIScreen.main.bounds.height) // ... constraints on subviews ]) } } class PresentedSubClass1 : PresentedBaseClass{ // ... } class PresentedSubClass2 : PresentedBaseClass{ // ... } class PresentingClass : UIView{ var windowFrame: CGRect init(windowframe: CGRect){ windowFrame = windowframe super.init(nibName: nil, bundle: nil) } @objc func originalPresentation(_ sender: UIButton){ childVC = PresentedSubClass1Controller(windowframe: windowFrame) present(childVC!, animated: false, completion: nil) // The two lines below are the original workaround //let appDelegate = UIApplication.shared.delegate //appDelegate?.window??.rootViewController = childVC } @objc func gotoSubClass1(){ childVC?.dismiss(animated: false, completion: nil) childVC = PresentedSubClass1Controller(windowframe: windowFrame) present(childVC!, animated: false, completion: nil) //let appDelegate = UIApplication.shared.delegate //appDelegate?.window??.rootViewController = childVC } @objc func gotoSubClass2(){ childVC?.dismiss(animated: false, completion: nil) childVC = PresentedSubClass2Controller(windowframe: windowFrame) present(childVC!, animated: false, completion: nil) //let appDelegate = UIApplication.shared.delegate //appDelegate?.window??.rootViewController = childVC } } class AppDelegate: UIResponder, UIApplicationDelegate{ var window: UIWindow? var PresentingController: PresentingController! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. window = UIWindow(frame: UIScreen.main.bounds) PresentingController = PresentingController(windowframe: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)) window?.rootViewController = PresentingController window?.makeKeyAndVisible() return true } }Apparently, the problem was that the presented view was not properly constrained; its subviews were, but it wasn't. See code above.
Post marked as solved
7 Replies
I actually get better behavior on iOS 12 if I change the rootViewController to the presented (vs presenting) view controller. What you say might be true on iOS 13, which could be why this workaround doesn't work there.
Post marked as solved
7 Replies
The automatic modalPresentationStyle is an iOS 13 thing. I get a compilation error if I try to set the modalPresentationStyle to automatic on iOS 12, thus it can not be the source of the issue I am experiencing on iOS 12. Thanks for your reply though.
Post not yet marked as solved
2 Replies
Fortunately for me, I wasn't lying when I said there was very little going on in this view other than what I mentioned. After a bit of futzing around, I was able to determine that viewDidAppear got called twice, and thus two timers were running and calling the selector. Initializing the timer only if it was currently nil solved the problem. Thanks for your help.
Post not yet marked as solved
8 Replies
This app is a game that kids might play with their friends. The scenario I am trying to avoid is where one kid, who is signed into the device with an Apple ID they do have permission to pay with, logs out of their game account (but not their Apple ID) and passes the game off to a friend who logs in with their own game account, but then makes an in-app purchase with the Apple ID of the first kid.In the case a password is required for the Apple ID every time, this is no problem; if they have set it to only require every 15 minutes, it might be. I guess I can mitigate this by tracking the time since the last in-app purchase, and if a game user logs out less than 15 minutes since that time, warn them to be sure their Apple ID isn't misused.Thanks for your replies, you all.
Post not yet marked as solved
8 Replies
Well, that's encouraging, but could you (or someone) justify that statement?