- Trending Categories
- 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 1966 Articles for Apps/Applications
815 Views
In this post we will be seeing how to get the touch position on device using Swift.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “TouchMe”Step 2 − Open Main.storyboard and add one label as shown below. On this label we will show the touch position.Step 3 − Create @IBOutlet for the label, name it touchPositionLabel.Step 4 − We will be overriding the touchesBegan method in ViewController to get the touch position in the view. Override the method as shown belowoverride func touchesBegan(_ touches: Set, with event: UIEvent?) { ... Read More
560 Views
In this post we will be seeing how to get the battery state in iOS.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “BatteryState”Step 2 − Open Main.storyboard and add two label as shown below. On this label we will show battery status.Step 3 − Enable the battery state monitoring, using the following code. You can put this code in viewDidLoad of ViewControllerUIDevice.current.isBatteryMonitoringEnabled = trueStep 4 − Declare a variable to hold the battery state. We will name this variable batteryState. From this variable we are returning UIDevice.current.batteryState, that would ... Read More
1K+ Views
In this post we will learn how to calculate the distance between two geo locations.We will show the distance between two points on a label.To do so follow the steps belowStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “FindDistance”Step 2 − Open Main.storyboard and add two labels as shown below.Step 3 − Attach one @IBOutlet for the bottom label. Name it distanceLabelStep 4 − Import CoreLocation framework in ViewControllerStep 5 − Add two points between which we want to find the distance as variablesvar firsLocation = CLLocation(latitude:34.54545, longitude:56.64646) var secondLocation = CLLocation(latitude: ... Read More
1K+ Views
Disabling scrolling in WebView in iOS is very simple.The ‘scrollView’ property of the WebView is exposed by iOS.You will just need to disable the scrolling of the corresponding scrollView using below code.webView.scrollView.isScrollEnabled = falseThe above code will disable the scrolling on WebView.If you were just looking to disable scrolling in web view above code would do that. If you want to know from scratch how to load WebView and disable scrolling. Follow along.Let’s create a sample project in XCode and learn the WebView loadingStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “WebViewScrollDisabling”Step ... Read More
2K+ Views
In this post we will be seeing how to customise iOS button.So let’s get started.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “CustomiseButton”Step 2− Open Main.storyboard and add a button as shown below. We will customize this buttonThere are two ways to customise this buttonUsing StoryboardStep 1 − Click on the buttonStep 2 − In the right panel, in the attribute inspector you can change the text color, text and background color of the button as shown belowRun the project you will see the customise button as belowNow we will see the ... Read More
3K+ Views
It’s very easy to check whether text field is empty or not in Swift.You will first need to check whether text is available or not in text field i.e. it’s not nil, then you will need to check if its present then its empty or not. Assuming myTextField is your text field variable name, you can do the followingif let text = myTextField.text, text.isEmpty { // myTextField is not empty here } else { // myTextField is Empty }Above code will check if textField is empty or not.If you want to look at how the text field can ... Read More
5K+ Views
In this post we will learn how to add top and bottom border to view.In this example we will take as sample view and add borders to it.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “AddBorderTopAndBottom”Step 2 − Open Main.storyboard add a UIView to it as shown below.Step 3 − Add one @IBOutlet for the view, name it centerView.Step 4 − We will write separate method to add borders to this view. To add borders to this view we will create two layers with desired thickness. We will set the frame of ... Read More
1K+ Views
In this post we will learn how to change the background color of view with animation.In this example we will change background color of view on click of a button. On clicking the button the background color will change to red, then on next click it would change to blue, on next click to red again.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “ChangeBGColor”Step 2 − Open Main.storyboard add a button as shown belowStep 3 − Add one @IBAction for touchUpInside of ‘Change Background’ button. Name the function as changeBackgroundClicked.Step 4 − ... Read More
981 Views
This example demonstrates how do I change current theme at runtime in my android app.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(android.R.style.Theme_Black); setContentView(R.layout.activity_main); } }Step 4 − Add the following code to androidManifest.xml ... Read More
4K+ Views
This example demonstrates how do I switch between different activities in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = findViewById(R.id.btnOpenAct2); ... Read More