iPhone/iPad Articles

Page 9 of 9

How to use Swift to detect when AVPlayer video ends playing?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

To detect the end of a video in swift we’ll need to create a video player, then use notifications to detect when the video stops playing. We’ll do this with help of an example in swift.Let’s create a project and drag and drop any video with extension “mp4”, select copy resource if required and add to the target of our project.Now we’ll programmatically first create a Video Player, then we’ll create url of the video in our project, and then we’ll play the video.var videoPlayer: AVPlayer!Now, in the viewDidAppear add the following code.override func viewDidAppear(_ animated: Bool) {    super.viewDidAppear(animated) ...

Read More

How to give dynamic height to UIlabel programmatically in swift?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 4K+ Views

To give a dynamic height to an UIlabel in swift we can use the frame property of UILabel. We can create a frame using the CGRect which allows us to give different variables like x position, y position, width, and height.Let’s create a label and add it as a subview to our view.let label = UILabel() label.frame = CGRect(x: 10, y: 40, width: 200, height: 50) label.backgroundColor = colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1) label.textColor = colorLiteral(red: 0.05882352963, green: 0.180392161, blue: 0.2470588237, alpha: 1) label.text = "Custom label" self.view.addSubview(label)We can embed this in a function as well, and ...

Read More

How to create scrollable TextView on iOS App?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 2K+ Views

To create a scrollable TextView in iOS we can do it in two ways, one by creating it using the storyboard and other by creating another textView programmatically.A text view is scrollable by default if it has text more than the height of textView and the scrollable property is disabled.1.Using storyboardGo to storyboard and from the object library drag a textView to your view.Now in the text view if the text is more than it’s height than it will be scrollable by default, otherwise it will not be scrollable.Give height constraint along with remaining required constraint.Make sure that scrolling enabled ...

Read More

How to detect swipe vertically on a ScrollView using Swift?

Samual Sam
Samual Sam
Updated on 30-Jul-2019 888 Views

To detect swipe in scrollView we will need to make use of some tricks as scroll view does not natively give the directions of scroll made on it. We’ll see this with help of an example.Create an empty project, add scroll view to the view as per your requirement.Give them constraint as required in the application.From the object library, drag and drop a swipe gesture recognizer right above the Scroll View.Select the gesture recognizer, go to its attribute inspector and from there, select the swipe option and set the value as “up”.When you do this, now your gesture recognizer can ...

Read More

How to add a Submit button after the end of the tableview using Swift?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

To add a submit button at the end of a table view, we can make use of table view footers. Let’s see this with help of an example where we’ll add a footer view to our table, and inside the table, we will add code for adding button at the bottom of the table view.Create a new project first, then inside the view controller add the following code which will initialize the table, add a section and a few rows to the table.func initTableView() {    let tableView = UITableView()    tableView.frame = self.view.frame    tableView.dataSource = self    tableView.delegate ...

Read More
Showing 81–85 of 85 articles
« Prev 1 5 6 7 8 9 Next »
Advertisements