how to embed YouTube video in iOS UITableViewCell - youtube

I would like to embed YouTube videos in UITableViewCells of my iOS app.
first of all I config the youtube-ios-player package in my Podfile using this command:
pod "youtube-ios-player-helper"
then I create a custom cell and add a YTPlayerView on each cell.
when I ran my app I found that the tableview stuck.So is there a better way to embed YouTube videos to my app.
thanks

Well after some research, I found a way that can make the tableview run fluently.
Try this url we will get a image:
https://img.youtube.com/vi/\(videoId)/0.jpg
I create a UIImageView on each cell.
When the user clicks on the cell, I call the playVideo() method.

Related

iOS Swift 4 before loading content

I build chat app using Firebase API right now. I wan't to make preload icons like on facebook screenshot. I thought i can create empty images and label fields and fill them after content loaded, but i don't know how to check if all data loaded from DB. How i can do that in correct way?
This is where i want to place objects
Install ListPlaceholder this lib.
import ListPlaceholder
To show the loader, start showing this from start
tableView.showLoader()
To hide the loader, end showing after data has been loaded
tableView.hideLoader()
Please refer this may get help.
https://github.com/malkouz/ListPlaceholder
Facebook has it's own library called Shimmer. To use this on tableview, you can follow this StackOverflow question answer.
You'll just have to create the UIView you want to animate and above that you'll have to add your FBShimmeringView. At the end set shimmeringView.shimmering = true to start shimmering
To hide the loading use tableView.hideLoader()
ListPlaceholder helped me to resolve the issue. All that I did was added the ListLoader.swift file to my project and added tableView.reloadData(), tableView.showLoader() in viewDidAppear in the tableView where I wanted to show loading.
( ListLoader.swif uses visibleCells to determine the number of rows on which the loading should be shown. In my applications, visibleCell's count was incorrect on calling tableView.showLoader() method in viewDidLoad )

PHLivePhoto Not Playing On UICollectionViewCell

I have created a UICollectionView that will display live photo's, the live photos are stored in an array and are working fine, except when i try to display them on the UICollectionViewCell's. They just wont play.
Here's what i tried : Added a UIView and changed its class to PHLivePhotoView, i've also tried adding an UIImageView and changing it's class just in case. I tried playing the live photos programmatically with:
cell.livePhotoView.startPlaybackWithStyle(PHLivePhotoViewPlaybackStyle.Full)
Which didn't work. Tried checking if my preview image was on top of the PHLivePhotoView, it wasn't the case.
If i take this route everything works fine
let livePhotoView = PHLivePhotoView(frame: self.previewImage.frame)
self.view.addSubview(livePhotoView)
livePhotoView.startPlaybackWithStyle(PHLivePhotoViewPlaybackStyle.Full)
The above works as expected.
Has anyone experienced the same issue? I don't know what i have overlooked.

Can I use the default UIBarButton icons provided by Apple in other assets of my app?

Like in UIButton or a UIImageView etc..
If so how do I do that using the StoryBoard or in a Xib
I am able to use the default icons inside UIBarButton items but cannot look them up in normal buttons . A solution using Storyboard would be really nice
In order to use them you need to extract them using a handy little app called (fittingly enough) iOS Artwork Extractor. I use it all the time when I want to mimic iOS system behaviours.
Download the Xcode project at:
https://github.com/0xced/iOS-Artwork-Extractor
Or another way:
The Other.artwork file is in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/ (you need the SDK).
Use the "iPhoneShop-1.3.jar" program -- available currently here to extract all of the images into a directory.
java -jar iPhoneShop-1.3.jar ARTWORK Other.artwork EXPORT Other
No you cannot use UIBarButtonItem on other as subview like UIButton. UIBarButtonItem can only over UINavigationBar.

UICollectionview with uidynamics reload data issue

I have been working on an app that uses UIDynamics in UICollectionView. I have watched Apple WWDC video and have also tried this sample app in Github.
However, I had this weird problem: When my app launches, I set the number of items for my collection view to 0, the app needs to download something from the server then populate the collection view on the main thread. Weirdly, it's (kinda) reloaded, but not showing anything. I tried on the sample app from Github and it has the same issue as well.
However, if I remove this part:
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect{
return [self.dynamicAnimator itemsInRect:rect];
}
The CollectionView will show what I want but without the UIDynamics.
I hope the illustration on my problem is easy to understand. Any help will be much appreciated. My guess is I shouldn't use reloaddata.

Custom info window for GMSMarker utilising UIWebView

I am using the Google Map iOS SDK for a project and have run into a problem whilst trying to implement a custom info window for a GMSMarker object. I have followed the Google video tutorial but instead of using A UILabel and UIImage, I am placing a UIWebView in the UIView as this will display HTML formatted text. However, when I run the code the UIWebView is always blank. If I replace with A UILabel the info window works. Has anyone else tried to use a UIWebView like this with the iOS SDK? I am wondering if it's related to the UIWebView taking too long to render?
last I checked the info window had to be a static uiview as it is rendered to an image. (same as markers are not UIViews but only static images)
the way I do it:
return an empty transparent view to the GMSMapView and THEN:
roll your own that you add as a subview yourself!
This link show what I described:
https://github.com/ryanmaxwell/GoogleMapsCalloutView

Resources