페이지

2020년 1월 14일 화요일

rootViewController is the first ViewController on Application stack


var firstNavigationController = UINavigationController(rootViewController: self.mainViewController )
window?.rootViewController = firstNavigationController


PopupViewController #3 : PopupViewController Style

override func viewWillAppear(_ animated: Bool) {

    super.viewWillAppear(animated)
    self.view.backgroundColor = UIColor(white: 0, alpha: 0.5)
    self.modalTransitionStyle = .crossDissolve
    self.modalPresentationStyle = .overCurrentContext
}

Add InitViewController

In App executing at first time, app sometimes have lots of tasks.


  • splash view showing
  • check app version
  • load app significant values from UserStandard or local storage
  • showing app usage info popup view ( it's a one-off )
  • locked screen for log-in
  • and so on
  • splash view hiding


class AppDelegate: UIResponder, UIApplicationDelegate {
    var window :UIWindow?
    var naviController :UINavigationController?
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        naviController = window?.rootViewController as? UINavigationController ;
        showSplash()
    }

    func showSplash(){
        let vc = UIViewController.instantiateViewController(storyboard: "Sotryboard", viewController: "\(InitViewController.self)" )
        window?.rootViewController = vc;
    }

}





class InitViewController: UIViewController{
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        checkInit()
    }


    func checkInit(){
        Async.serial(tasks: [
        {  done in
            task1 {
                done(nil)
            }
        }
        ,
        { done in
            task2 {
                done(nil)
            }
        }
        ,
        { done in
            //chage rootViewController.
            UIApplication.appDelegate?.window?.rootViewController = UIApplication.appDelegate?.naviController
            self.dismiss(animated: true, completion: {
                    done(nil)
            })
        }

    }

}



PopupViewController #2 : PopupViewController must check if another popupView is presenting


if let vc = UIApplication.rootViewController?.presentedViewController {
    vc.dismiss(animated: false) {
        UIApplication.rootViewController?.present( myPopupVc, animated: true, completion: nil )
    }
} else {
    UIApplication.rootViewController?.present( myPopupVc, animated: true, completion: nil)
}

PopupViewController #1 : use rootViewController.present when presenting Pop Up ViewController

When we are going to show Custom Popup Style ViewController, It's good to use rootViewController.present(,,,, )  method.

.rootViewController?.present( myPopupViewController, animated: true, completion: nil )

Reason 1.

self.present( myPopupViewController, animated: true, completion: nil )
    //self : SomeViewController


if self(SomeViewController) has dismissed while presenting myPopupViewController, myPopupViewController also will be dismissed without user's interaction.








2019년 11월 28일 목요일

C# Extension vs Swift Extension

C# Extesion


using System;
                    
public class Gun{
    public void fireDoubles(){
        fire(); // error: 'fire' does not exist in the current context
        
        this.fire(); // ok

        Console.WriteLine("fire2");
    }
}


public static class GunExtension{
    public static void firethis Gun gun ){
        Console.WriteLine("fire");
    }
}

public class Program
{
    public static void Main()
    {
        var gun = new Gun();
        gun.fireDoubles();
    }
    


}


Swift Extesion


import Foundation

class Gun {
    func fireDoubles(){
        fire() // no error
        print("fire2")
    }
}

extension Gun {
    func fire(){
        print("fire")
    }
}

let g = Gun()
g.fireDoubles()

2019년 4월 29일 월요일

"The address entered appears to be invalid." in app Store Connect

When this error comes on in app store connect page, delete last hidden character in each address field.