Here is how to programmatically set icon / image for Tab Bar Item in UITabBarViewController

Assumptions: I assume you have already embedded in UITabBarViewController for your ViewController in Interface Builder. I also assume you have three tab bar items with individual view controllers and further you have created images assets with your icon images.

 
Solution is simple you have to copy following code in your current View Controller’s ViewdidLoad method.

(more…)

Continue Reading Post

How to programatically change titles of tabs in UITabBarViewController and here is how to programatically change title of individual View Controllers at Navigation Bar inside individual UITabBarViewControllers.

Let’s assume you are using Tab Bar View Controller in your Xcode Apple iOS App Project.

 
You have embedded in your view controller with UITabBarViewController.

 
Say, you are using 3 Tab Views.

 
In Swift programming Language number counting starts with 0 so you will write code like this in your respective view controller’s viewDidLoad function.

(more…)

Continue Reading Post

Here is how to change < Back button text of your Apple iOS App

While we use app development methodology like MVC (Model, View, Controller) we encounter problem while navigating from one view to another how to change text of back button which get populated automatically by Apple iOS Operating System.

 
You can use below method in viewDidLoad method of your root view:

 

navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)

 
Here is another way of doing the same which can be done in ‘prepare for segue’ method of your app:

(more…)

Continue Reading Post

Here is how to programmatically identify if user is on iPhone or iPad. There is also way to find out if user is on either device and if it is in portrait mode, landscape mode.

We will explore our ways to identify device of user whether it is iPad or iPhone, We will do all this in Swift Programming Language with latest Xcode build.

 
There four ways that iOS device will get identified .phone, .pad, .tv & .unspecified.

 
So code will look like this in swift

 
Code for iOS 13, iPadOS 13, macOS 10.15 Catalyst and above:

 

if UIDevice.current.userInterfaceIdiom == .phone {
    
} else if UIDevice.current.userInterfaceIdiom == .pad {
    
} else if UIDevice.current.userInterfaceIdiom == .carPlay {
    
} else if UIDevice.current.userInterfaceIdiom == .tv {
    
} else if UIDevice.current.userInterfaceIdiom == .unspecified {
    
}

 
Code for iOS 12 and below:

 

if (UIScreen.main.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiom.pad) {
    print("It's iPad")
    // Your code here
    
} else if (UIScreen.main.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiom.phone) {
    print("It's iPhone")
    // Your code here
    
} else if (UIScreen.main.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiom.tv) {
    print("It's Apple TV")
    // Your code here
    
} else if (UIScreen.main.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiom.unspecified) {
    print("It's Unknown Device")
    // Your code here
    
}

(more…)

Continue Reading Post

What is Apple Store Kit Framework and how to write code for SKStoreReviewController API which will prompt user to write review for you App while using your app & without leaving your app

Introduction to StoreKit and Apple App Store policies

 
I will write down few concepts & ideas to help you understand to implement StoreKit app review functionality in your app using Xcode.

 
Important Points to remember

 
You can ask your users to rate your app on a scale of 1 to 5 stars. User can also choose to write review for iOS and macOS apps.

 
Developer can view, sort and respond to reviews in iTunes Connect.

 
About Summery of Ratings

 
Every App Store app has one summary rating on product page, specific to each territory on the App Store.

 
Developer can reset your app’s summary rating with release a new version of app.

(more…)

Continue Reading Post

How to fix if ‘My Photo Stream’ is not working on your Apple iOS Devices including iPhone, iPad and iPod touch

I have jot down few points to check why My Photo Stream is not working in your iOS Device & syncing Photos across iOS & OSX devices.

 
Solution & Few Check Points:

  1. You are sign in to iCloud using your preferred active Apple ID
  2. ‘My Photo Stream’ is checked & on your device under iOS Settings App under iCloud Photos related Section
  3. (more…)

Continue Reading Post

How to fix if ‘My Photo Stream’ is not working on your Macintosh / OSX including on your iMac, MacBook, MacBook Pro, MacMini, Mac Pro Computers

Here is the solution if your ‘My Photo Stream’ iCloud Apple Photos App feature is not working correctly.

 
Assumption:

  1. You have sign in your iCloud Account on Your Mac
  2. My Photo Stream is selected & Active inside your System Preferences > iCloud > Photos App Settings

(more…)

Continue Reading Post

How to identify user is on iPhone, iPad or iPod touch by accessing their device width property. In other words how to write conditional code for 3.5 inch iPhone, 4 Inch iPhone, 4.7 inch iPhone, 5.5 inch iPhone, 9.7 inch iPad, 12.9 inch iPad

You may be programming Universal App for iPhone, iPad, iPad Pro & iPod touch. And you may be wondering how to write conditional code for that variant iOS device sizes.

 
So here is how to write code by identifying device height of your display or frame.

 
Here is how to solve this situation by identifying device height,

 

Note: This code uses native bounds of device so this code will work for all current devices that may be in landscape or portrait mode. Code is written in Swift Programming Language.

(more…)

Continue Reading Post

How to secure macOS – OSX & iOS Wi-Fi Network with recommended settings for Wi-Fi routers and access points

I will list down steps to secure your macOS & iOS Wi-Fi Network.

 

Step 01: First things first, Update you Macintosh, iPhone, iPad, iPod touch & even AirPort Express, Airport Extreme base stations for latest software using Mac App Store.

 

Step 02: Choose Unique & Safe SSID (Service Set Identifier) Wi-Fi network name

 
Wi-Fi network name is case sensitive. Choose a unique name for your network and that isn’t shared by other nearby networks. If your SSID isn’t unique, Wi-Fi devices will have trouble identifying your network. This could cause network device to fail to automatically connect to your network, or to connect to other networks sharing the same SSID.

(more…)

Continue Reading Post

Here is how you can call method or function in FirstViewController.swift from another Class called SecondViewController.swift in your iOS or macOS project within Xcode

Here is situation in your Xcode project that you want to call method from another class swift file to your original class of swift file.

 
Let’s call your original swift class file ‘FirstViewController’ which has ‘UIViewController’ as super class.

 
Second swift that you want to call function from we will assume that it has ‘SecondViewController’ as class name & it has ‘UIViewController’ as super class.

 
You have written function called ‘printSomething()’ in your ‘SecondViewController’ that would be triggered when somebody taps on button present on ‘FirstViewController’ as IBAction called ‘printThis(sender: UIButton)’

 
So you will write printThis function as follows:

(more…)

Continue Reading Post