Found 1912 Articles for Mobile Development

How to hide Back Button on navigation bar on iPhone/iPad?

Nishtha Thakur
Updated on 27-Jun-2020 13:17:29
To hide the back button on navigation bar we’ll have to either set the navigation button as nil and then hide it or hide it directly.Let’s create a project, add 2 view controller and Embed them in navigation controller. Let’s see how this project looks when run without any code to remove the navigation bar.This code set’s the navigation bar’s back button as hidden.self.navigationController?.navigationItem.hidesBackButton = trueThis code set’s the navigation bar’s back button as nilself.navigationItem.leftBarButtonItem = nil;A combination of these to approaches would be a better solution and works even if you have set a custom navigation bar.self.navigationItem.leftBarButtonItem = nil ... Read More

How to take a screenshot of my iOS application in the iOS simulator?

Smita Kapse
Updated on 27-Jun-2020 13:18:30
To take a screenshot of an iOS Application running in Simulator you can you any of the below ways.Capturing device Screen − you can capture your Mac's screen from the area your simulator is running in. to do this you have to press, Command, shift and 4 at the same time, then drag to select the area you want to capture. Alternatively you can press 3 instead of 4 to capture the whole screen.Open simulator, and press Command along with S at the same time, this will take a screenshot and save on desktop can also open simulator, go ... Read More

How to create a Border, Border radius, and shadow to a UIView in iPhone/iOS?

Nancy Den
Updated on 27-Jun-2020 13:19:37
In this article we’ll learn how to create borders and shadows. We’ll do it in two ways, one by directly coding and one by making it designable and an extension of UIView, which can be edited directly in the storyboard.Let’s see how to play around with borders in ios −Method 1 − Creating borders with simple coding –Borders are a property of layer, above which a View is drawn, a border has the following properties, Border color, border width.self.view.layer.borderColor = colorLiteral(red: 0.4392156899, green: 0.01176470611, blue: 0.1921568662, alpha: 1) self.view.layer.borderWidth = 5.0To create corner radius of a view we can useself.view.layer.cornerRadius ... Read More

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

Nitya Raut
Updated on 27-Jun-2020 13:21:09
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
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
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
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
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
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
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