Found 208 Articles for IOS

How to lock & unlock the iOS device programmatically

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

457 Views

Locking of iOS device cannot be done programmatically without the use of Private API’s. One such private API’s GSEventLockDevice() (private API) from GraphicsServices.framework which might help you achieve your persona but the application would result in rejection from Apple’s App Store.More over there’s no documentation provided by apple for the same.On a final note you cannot achieve this functionality without using the Private API’s and if you are using your application will be rejected by Apple.

How to Ping External host from Swift in iOS?

Smita Kapse
Updated on 30-Jul-2019 22:30:26

843 Views

Sometime you may require to ping an external website and check whether it’s up and running before you do any processing or fire request on the same.Here we will be seeing how to check whether the external website is up and running.Let’s being by Creating new projectStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “PingMe”Step 2 − Open ViewController.swift and add the function checkIsConnectedToNetwork() and add the following code.func checkIsConnectedToNetwork() {    let hostUrl: String = "https://google.com"    if let url = URL(string: hostUrl) {       var request = URLRequest(url: ... Read More

How to execute a task repeatedly after fixed time intervals in iOS

Anvi Jain
Updated on 30-Jul-2019 22:30:26

217 Views

Apple has predefined class Timer, that fires after a certain time interval has elapsed, sending a specified message to a target object.To read more about the Timer class you can check official apple documentation herehttps://developer.apple.com/documentation/foundation/timerTo execute the task repeatedly after fixed interval of time we are going to use timer class. We are going to develop a sample application where the application prints hello Tutorials Point after every 5 seconds.So let’s get started, Step 1  − Open Xcode → New Project → Single View Application → Let’s name it “HelloTutotrialsPoint”Step 2  − Open ViewController.swift and write one method doSomething() below ... Read More

Working with Xcode Auto Layout in Swift and iOS

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

2K+ Views

Auto layout is constraint based layout system used for development of User Interfaces for iOS Devices. This layout based constraint system also known as Auto Layout is basically an adaptive UI which adapts to screens of different sizes and orientations.Auto layout is completely dependent on constraints where developer defines a relation between neighbouring or parent element to seize it position.Why Auto Layout?While designing an iOS application you need to make sure, the UI which you’re developing should be equally compatible with all screen sizes and orientation. Auto layout comes handy when you wish to do so.Consider below images. A centrally ... Read More

Where are the app cookies stored on the iPhone?

Smita Kapse
Updated on 30-Jul-2019 22:30:26

4K+ Views

Cookies are small files which are stored on a user's device while browsing internet.When we talk about cookies in iPhone we usually talk about application using the Web Views or the browser applications.A normal iOS application does not contains cookies. An app will have cookies only if the application has one or more web views.To check where are the app cookies stored on iPhone, On an iPhone, go to Settings -> Safari -> Advanced -> Website Data and you will see all cookies stored on your device.For iOS Application using web view The UIWebView will automatically store the cookies in the sharedHTTPCookieStorage.Read More

How to lock Screen Orientation programmatically in iOS?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

You might come across a scenario where you need to show the UI in a specific orientation may be Landscape or Portrait.We will be seeing how to lock orientation programmatically using Swift in iOS.Open Xcode → New Project → ViewController.swift write the below code.// Set the shouldAutorotate to False override open var shouldAutorotate: Bool {    return false } // Specify the orientation. override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {    return .portrait }

How to check if Location Services are enabled in iOS App?

Anvi Jain
Updated on 30-Jul-2019 22:30:25

1K+ Views

Location services as the name suggests gather the user information via GPS, Wifi and cell towers. Every iOS device has on board GPS, WiFi, cell tower location data and Bluetooth to determine the location of the iPhone or iPad. The user can enable or disable location services from the Settings app by toggling the Location Services switch in General.You should check the return value of locationServiceEnabled() method before starting location updates to determine whether the user has location services enabled for the current device.To check if Location Services are enabled in iOS app checkout the codeOpen Xcode → New Project ... Read More

How to detect iOS device UDID, Name, Version, Model by programmatically?

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

Device UDID stands for Unique device identifier. Every iOS Device has UDID which is a sequence of 40 letters and numbers that is guaranteed to be specific to your device.Device name is generally a name which will find in the device Setting→ General→ About.iOS Version is the version on which your current iPhone runs, latest iOS version in 12.2iOS Model describes whether the iOS device which user is using is an iPhone/iPad.Now will see how to detect UDID, Name, Version and Model programatically.Open Xcode → New Project and add the below code in ViewController’s viewDidLoad method.override func viewDidLoad() {   ... Read More

How to get device make and model on iOS?

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

When we talk about the device make, we refer to the Phone manufacturer (e.g. Apple, Samsung, Nokia and so on) and device model is generally the specific product such as iPhone, iPad/TAB etc.Any mobile devices will be categorized using make and model only.Now let’s understand how do I get device make and model in iOS?There are two ways to get make and model the first way is to directly open your iOS device, navigate to setting, tap on general and in the about section you can find the details of your iOS deviceThe second way is getting make and model ... Read More

Aligning two buttons vertically in iOS

Anvi Jain
Updated on 30-Jul-2019 22:30:25

569 Views

Auto Layout is one the most important element when it comes to designing an iOS Application. UI development has become a lot more versatile and easier using Auto Layout.For Aligning two buttons vertically we will be using Auto Layout.So let’s get started!Step 1: Open Xcode → New Projecr → Single View Application → Let’s name it “AlignButtons”Step 2: Open Main.storyboard and add two buttons, name them button 1 and button 2.Step 3: Select both the buttons and align them vertically using the Add New Alignment Constraint menu.Step 4: Select both the buttons tap on Add new constraints and set it ... Read More

Advertisements