- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 208 Articles for IOS
1K+ Views
Coming from Objective C- Background now we don’t need to use NSDate as Swift has defined its own struct type Date. Date bridges to the NSDate class. You can use these interchangeably in code that interacts with Objective-C APIs.To read more about Date you can check official apple docs https://developer.apple.com/documentation/foundation/dateIn this post we will be seeing how one can create date object, So let’s get started we will be using Playground for this purpose.First, we will be seeing how to get the current date and time (UTC), to get current date and time, create an object of Date, enter the ... Read More
887 Views
There are numerous application which either runs on Portrait mode or in Landscape mode.Restricting the application in one of the mode is important to achieve this.In this post we will see how to restrict the orientation or disable the orientation to one mode.If you want the application to be running only in Portrait mode, Below your viewDidLoad method copy the below line of codeoverride var supportedInterfaceOrientations: UIInterfaceOrientationMask { get { return .portrait } }This will lock the landscape mode for your application. Similarly by replacing .portrait to .landscape will run your application in landscape mode.If ... Read More
379 Views
Working with date and time can be tricky, I’ve seen new programmers struggling with date and time. In almost all the application you will be required to get the date and multiple operations are dependent on it.Here we will be seeing how to get the current date and time in swift.In this post we will be seeing how to get the current time and UTC time.For getting the UTC time, paste below code in playground.let utcDate = Date() print(utcDate)If you wish to get the time stamp of your location, paste the below code in playground.let dateObj = Date() let datetformatter ... Read More
367 Views
Getting difference between two dates is easy. You should know how to play between the dates.We will be using DateFormatter class for formatting the dates.Instances of DateFormatter create string representations of NSDate objects, and convert textual representations of dates and times into NSDate objects.You can read more about it here https://developer.apple.com/documentation/foundation/dateformatterWe will also be using Calendar structure, apple has provided beautiful documentation of it, https://developer.apple.com/documentation/foundation/calendarSo let’s get started.Open Xcode, New Playground.Copy the below codeimport UIKit // create object of DateFormatter and Calendar let formatter = DateFormatter() let calendar = Calendar.current // specify the format, formatter.dateFormat = "dd-MM-yyyy" // specify the start ... Read More
199 Views
As of now, there’s no way you can access both front and back cameras simultaneously. As both cameras have different session, as soon as one will start other session will die.As per the apple developer forum answered by Apple support team −“Apps cannot capture from the front and back cameras simultaneously. You can switch from one to the other (with a short delay between) but not both at the same time”
561 Views
Knowing when the application is in foreground or in background is important as being an iOS developer we need to handle multiple events such as background downloads, events if the app comes to foreground.Here we will see how to check if the application is in background or foreground.We will be using Notification Center for that, To read more about it you can refer apple document. https://developer.apple.com/documentation/foundation/notificationcenterA notification dispatch mechanism that enables the broadcast of information to registered observers. We will be adding observer to the same and will be getting the call.Step 1 − Open Xcode → New Project → Single ... Read More
2K+ Views
Table View is one of the most important and fundamental part of iOS application, Every iOS developer should be familiar with it.Almost every application you see in App store use table view.Table views on iOS display a single column of vertically scrolling content, divided into rows. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settingsYou can read more about table view here, https://developer.apple.com/documentation/uikit/uitableviewIn this post we will see ... Read More
232 Views
It is very important to know when user is pressing home key as it puts the application to background, here we will be seeing how to identify or get a call when user presses home key.In you AppDelegate.swift, there are delegates methods.Open your AppDelegate.swift and in applicationWillResignActive(_ application: UIApplication) and applicationDidEnterBackground(_ application: UIApplication), write print statement and put a breakpoint as shown.Run the application, once the app is launch tap the home button, applicationWillResignActive will be called and then applicationDidEnterBackground.
1K+ Views
There will be instance where you might get a requirement to control / manipulate width and height the Alert while developing iOS application. If you’re not familiar with the same, it can trouble you.Here we will be seeing how to control the width and height of default alert box, For controlling the height and width we will be using NSLayoutConstraint.To read more about UIAlertController refer − https://developer.apple.com/documentation/uikit/uialertcontrollerIn this, we will be creating a new project where we will have a button, on tapping that button we will show alert with custom message.Step 1 − Open Xcode → New Project → Single ... Read More
1K+ Views
When most apps have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power.Preventing iOS Device from going to sleep is easy, navigate to your Settings → Display & Brightness → Autolock, select never.This will never lock your screen.If you’re developing an iOS Application and you’re required to implement this feature, you should use isidletimerdisabled provided by apple, to read more about it https://developer.apple.com/documentation/uikit/uiapplication/1623070-isidletimerdisabledIn your viewDidLoad method write the following line of code to prevent the device from going to ... Read More