Thursday, 29 June 2017

UIScrollView's origin changes after popping back to the UIViewController


override func viewWillAppear(_ animated: Bool) {
        
        self.Scrollview.contentOffset = CGPoint(x: 0,y :0)

    }

Wednesday, 28 June 2017

how to Scroll(horizontally) in collection view on button press?

https://stackoverflow.com/questions/34024031/how-to-scrollhorizontally-in-collection-view-on-button-press

How to Apply Gradient to background view of iOS Swift App

https://stackoverflow.com/questions/24380535/how-to-apply-gradient-to-background-view-of-ios-swift-app

Saturday, 24 June 2017

Create UIWebView Programmatically and Load Webpage Using NSURL

  1. class ViewController: UIViewController, UIWebViewDelegate {
  2. override func viewDidLoad() {
  3. super.viewDidLoad()
  4. // Do any additional setup after loading the view, typically from a nib.
  5. let myWebView:UIWebView = UIWebView(frame: CGRect(x:0, y:0, width: UIScreen.main.bounds.width, height:UIScreen.main.bounds.height))
  6. self.view.addSubview(myWebView)
  7. myWebView.delegate = self
  8. //1. Load web site into my web view
  9. let myURL = URL(string: "http://www.swiftdeveloperblog.com")
  10. let myURLRequest:URLRequest = URLRequest(url: myURL!)
  11. myWebView.loadRequest(myURLRequest)
  12. }

How to check if a file exists in Documents folder?

let documentsURL = try! FileManager().url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) let fooURL = documentsURL.appendingPathComponent("foo.html") let fileExists = FileManager().fileExists(atPath: fooURL.path) if fileExists==true { print("already existed") } else { print("no file") }

https://stackoverflow.com/questions/1638834/how-to-check-if-a-file-exists-in-documents-folder

Friday, 23 June 2017

Enable zooming/pinch on UIWebView

1)you can use webView.scalesPageToFit=YES; programmatically


2)If you are using in xib than just click the check box "Scaling" scales Page to fit

Wednesday, 21 June 2017

Go to rootView when tabBar tapped

import UIKit

class RootviewTabViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
        let rootView = self.viewControllers![self.selectedIndex] as! UINavigationController
        rootView.popToRootViewController(animated: false)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

  
}

Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...