Mohtashim M

Mohtashim M

28 Articles Published

Articles by Mohtashim M

28 articles

How to create CollectionView Layout in an iOS App?

Mohtashim M
Mohtashim M
Updated on 03-Jul-2020 503 Views

CollectionView with TableView are two of many fundamental concept of iOS development, every developer should master both to be a good developer.In this post we will be focussing mainly on CollectionView, CollectionView is same as table view with some difference, Collection View supports both horizontal and vertical scrolling which looks like a grid. CollectionView in iOS is also referred to grid view in Android.To read more about it you can refer https://developer.apple.com/documentation/uikit/uicollectionviewAs you can see Collection View consists of Supplementary View and Cell, The collection view presents items onscreen using a cell, which is an instance of the UICollectionViewCell class ...

Read More

How to prevent the screen from sleeping in iOS?

Mohtashim M
Mohtashim M
Updated on 16-Dec-2019 389 Views

In this post we will be seeing how to prevent screen from sleeping in iOS.So, let’s get started.Copy the below line of code in viewDidLoad method in ViewController.Swiftoverride func viewDidLoad() {    super.viewDidLoad()    // Do any additional setup after loading the view, typically from a nib.    UIApplication.shared.isIdleTimerDisabled = true }Run the application, the application will never go in sleep mode.

Read More

How to create Tab Bar Layout in an iOS App?

Mohtashim M
Mohtashim M
Updated on 16-Dec-2019 393 Views

In this post we’re going to see how one can use tab bar layout in their application.As per apple’s documentation −A tab bar appears at the bottom of an app screen and provides the ability to quickly switch between different sections of an app. Tab bars are translucent, may have a background tint, maintain the same height in all screen orientations, and are hidden when a keyboard is displayed. A tab bar may contain any number of tabs, but the number of visible tabs varies based on the device size and orientation.You can read more about the same herehttps://developer.apple.com/design/human-interface-guidelines/ios/bars/tab-bars/So let’s ...

Read More

How do I programmatically “restart” an iOS app?

Mohtashim M
Mohtashim M
Updated on 16-Dec-2019 2K+ Views

You cannot restart an iOS Application in any case, even if you’re able to do using some private api your application will be rejected by Apple and will not be considered for App store release.

Read More

How to create a file, write data into it and read data from it on iOS?

Mohtashim M
Mohtashim M
Updated on 16-Dec-2019 1K+ Views

Being a software developer we should be always aware of how to play with files, write to a file, read from the file and so on.In this post we are going to learn the same, we will be creating a file and writing the data to the file and later reading through the same file.So let’s get started, Step 1 − Create new Xcode Project → Single View Application → name it “ReadingWritingFile”Step 2 − Open ViewController.swift and add new function as show belowpublic func createAndWriteFile() { }Now we will create a file and will print the path of the ...

Read More

How to call a method after a delay in Swift(iOS)?

Mohtashim M
Mohtashim M
Updated on 23-Oct-2019 2K+ Views

In this post, we will be seeing how you can delay a method call using Swift. Here we will be seeing how you can achieve the same in two ways, So let’s get started, We will be seeing both the example in Playground, Step 1 − Open Xcode → New Playground.In the first approach, we will be using asyncAfter(deadline: execute:) instance method, which Schedules a work item for execution at the specified time and returns immediately.You can read more about it here https://developer.apple.com/documentation/dispatch/dispatchqueue/2300020-asyncafterStep 2 − Copy the below code in Playground and run, func functionOne() {    let delayTime = ...

Read More

How to rotate an image in imageview by an angle on iOS App using Swift?

Mohtashim M
Mohtashim M
Updated on 23-Oct-2019 4K+ Views

Images are everywhere almost in all application, you might have come across many applications like gaming applications where you see images getting rotated.So, In this post, we will be seeing how to rotate the image in an image view by an angle in an iOS application.So, Let’s get started, Step 1 − Open Xcode→SingleViewApplication→name it RotateImage.Step 2 − Open Main.storyboard, add UIImageView and add 2 buttons as shown below name them ROTATE BY 90 DEGREES AND ROTATE BY 45 DEGREES. Add some sample images to UIImage View.Step 3 − Create @IBAction for both buttons and name them as rotate45button and ...

Read More

How to create Picker programmatically from array in iOS?

Mohtashim M
Mohtashim M
Updated on 30-Aug-2019 2K+ Views

A picker view displays one or more wheels that the user manipulates to select items. Each wheel—known as a component—has a series of indexed rows representing the selectable items.UIPicker is one of the important components and almost used in most of the applications. You’ll see them mostly in form-based applications.You can read more about it here: https://developer.apple.com/documentation/uikit/uipickerviewIn this post, we will be seeing how to create UIPicker programmatically from and array and load array values into it.So let’s get started, Step 1 − Open Xcode and create a single view application and name it PickerSample.Step 2 − Open ViewController.swift, Since ...

Read More

How to dismiss the Alert with click on outside of the alert in iOS?

Mohtashim M
Mohtashim M
Updated on 30-Aug-2019 3K+ Views

Understanding and implementing UIAlert can be tricky especially if you’re new to iOS Development, In this post, we will be seeing how we can dismiss the alert when the user taps outside the alert box.For this demo, we will be using UIAlert class, to configure alerts and action sheets with the message that you want to display and the actions from which to choose. After configuring the alert controller with the actions and style you want, present it using the present(_:animated: completion:) method. UIKit displays alerts and action sheets modally over your app's content.You can read more about it: https://developer.apple.com/documentation/uikit/uialertcontrollerSo ...

Read More

How to change screen brightness programmatically in iOS?

Mohtashim M
Mohtashim M
Updated on 30-Aug-2019 1K+ Views

To change the brightness of the screen we have to use the brightness property of the screen, This property is only supported on the main screen. The value of this property should be a number between 0.0 and 1.0, inclusive.Brightness changes made by an app remain in effect until the device is locked, regardless of whether the app is closed. The system brightness (which the user can set in Settings or Control Center) is restored the next time the display is turned on.It’s an instance property, To implement this in your iOS Application (any application) add below line in viewDidLoad ...

Read More
Showing 1–10 of 28 articles
« Prev 1 2 3 Next »
Advertisements