Found 98 Articles for IPhone/iPad

How do I draw a shadow under a UIView in iPhone/iOS?

Nitya Raut
Updated on 27-Jun-2020 13:21:09

148 Views

To make our UI appealing, we have to play around with multiple attributes in iOS development. To draw shadows around a View or below a view we have to play around Layers and Views.Let’s see this in two ways.Method 1 − Simply coding where ever required.self.layer.masksToBounds = NO; self.layer.cornerRadius = 2; self.layer.shadowOffset = CGSizeMake(-5, 10); self.layer.shadowRadius = 3; self.layer.shadowOpacity = 0.3;Method 2 − Creating IBDesignable and IBInspectable and Using with Story board.@IBDesignable class DesignableView: UIView { } extension UIView {    @IBInspectable    var shadowRadius: CGFloat {       get {          return layer.shadowRadius     ... Read More

How to disable the network in iOS Simulator?

Nishtha Thakur
Updated on 27-Jun-2020 13:23:06

8K+ Views

Sometimes while testing our app on simulator we need to test for case where no internet is available. This can be achieved in multiple ways.Below are some of the possible ways to do itEasiest but not the most correct way is to disconnect your mac from the LAN Cable is you are on a LAN, or turn off the wifi if you are connected on a wifi network. But that will definitely turn off internet for your whole device, not just simulator. So, there are some more ways to do itDownload Hardware IO tools for Xcode.Go to Xcode menu, select ... Read More

How to go through all text fields with the "Next" Button on the iPhone/iOS Keyboard?

Smita Kapse
Updated on 27-Jun-2020 13:24:46

804 Views

To go through all the text fields one by one on tap on done or return button, we’ll have to create a logic. Let’s understand it with help of a project.Create a project and on the view controller story board drag Four text fields.Select them one by one and from attribute, inspector set their tags as 1, 2, 3, 4 respectively.Also set their return key to Done from the attribute inspector itself.Create outlets for all four text fields in the View controller class, connect them to their respective outlets.@IBOutlet weak var tf1: UITextField! @IBOutlet weak var tf2: UITextField! @IBOutlet weak ... Read More

What is Xcode error “Could not find Developer Disk Image”?

Nancy Den
Updated on 27-Jun-2020 13:25:20

510 Views

The Xcode error occurs when the xcode version and ios versions don’t match. Usually it happens when the Xcode version is less than the device iOS version. i.e. the Xcode is too old for the device. This is a compatibility issue which can be resolved by performing some steps.Always check if the device you are using has compatible iOS version to the Xcode version, if not Xcode requires an update.If you are not able to update XCode or there is no update being shown for Xcode, please check if the OS needs an update.In some cases you would not like ... Read More

How to take a screenshot programmatically in iPhone/iOS?

Nitya Raut
Updated on 27-Jun-2020 13:26:08

967 Views

Though iOS does not provide any official way to take screenshots on iOS device programmatically, it provides a way to screenshot using the home and power button, by pressing both of them at the same time.To take a screenshot, we’ll have to go through a series of steps.We’ll get the layer of keyWindow – UIApplication.shared.keyWindow!.layerWe’ll get the scale of screen – UIApplication.main.scaleCreating a new image with same size as the view.Render and save the image.Let’s create a new project, in the main view controller give some background color and then drag a button and connect to create an action to ... Read More

How to exit iPhone application gracefully?

Nishtha Thakur
Updated on 27-Jun-2020 13:28:13

295 Views

There are times we would like to close our application due to some reason, for example if there is no internet connection and you’d like to kill the app, or any other reason according to the application. Though apple prefers not quitting the application, hence it is not supported in any of the applications.The only way to logically kill an iOS application is by pressing the home button. As soon as the home button is pressed, and the application exits the memory is freed up and cleaned.Still there are other ways to quit an application.exit − this command may be ... Read More

How to URL encode a string (NSString) in iPhone?

Smita Kapse
Updated on 27-Jun-2020 13:28:31

456 Views

When developing API based web applications we definitely need to interect with Multiple web services and URLs. The url may contain special character, search terms, queries, headers and many other things depending on the service we need. That’s why we need to have some kind of encoding so that the URL we are creating and the URL being called are same.To achieve the same with Objective C we can use −#import "NSString+URLEncoding.h" @implementation NSString (URLEncoding) -(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding {    return (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,    (CFStringRef)self, NULL, (CFStringRef)@"!*'\"();:@&=+$, /?%#[]% ", CFStringConvertNSStringEncodingToEncoding(encoding)); } @endAnother way to achieve URL encoding in Objective C is ... Read More

How to parse JSON object in iPhone/iOS?

Nancy Den
Updated on 27-Jun-2020 13:29:49

421 Views

JSON stands for Javascript object notation. Most of the when dealing with APIs or any other services the data is returned in JSON format and we need to convert it to usable and supporte language formats.Foundation framework of iOS provides a class JSONSerialization to convert JSON into supported formats like Dictionary, strings, Bool etc.The JSONSerialization class provides a method jsonObject(with:options:) that parses json and returns Any as result, and an error if the data cannot be parsed.// Example JSON: /* {    "age": 42.0,    "name": {       "firstName": “tut”    } } */Let’s see this with help ... Read More

What are all the custom URL schemes supported by the Facebook iPhone app?

Jennifer Nicholas
Updated on 27-Jun-2020 13:31:00

608 Views

A url Scheme is a way of iOS to open some third party applications from within a app. Some of the URL schemes that are supported by facebook to open different modules of facebook app from within some other app are mentioned below.1. To open facebook profile: fb://profile 2. To open request list: fb://requests 3. To open friends list : fb://friends 4. To open notes: fb://notes 5. To open the list of notifications : fb://notifications 6. To open albums: fb://albums 7. To open feeds/ home : fb://feed 8. To open events : fb://events 9. To open a page with id: ... Read More

How to launch any arbitrary iPhone application from within another app?

Nitya Raut
Updated on 27-Jun-2020 13:31:34

686 Views

iOS Allows us to open some applications with some links or other ways from our app, like dialing a number when clicked on it, or writing a mail with some static body or writing a SMS. But this is limited to some applications, not every app can be opened from within an application.Specifically it is limited to apps that have a registered URL Scheme. For example if you want to open a SMS from your app, it is possible using the registered URL Scheme.Some of the applications that can be opened with URL schemes and how to open them are ... Read More

Advertisements