This is NOT a test for TMDB.
This is a TEST of UIStackView
Link to iosTest2.app
https://1drv.ms/u/s!ApN1U-GH6AeIlxuHE...
===============================
A. Standalone (Top Banner)
// only 3 pages, to avoid server timeOut.
// ( reduce or Increase )
ViewDidLoad- GT Fetch 3 pages
on Page Count == 3 (not Page Number)
self.PopulateBannerStackView(stackView: self.stackView,
maximum: 100, width: 150, height: 220, child: self.currentItems)
================================
B. Inside a UICollectionView's Cell
on Item Request (UICollectionView's Protocol)
let t1 : String = currentItems[indexPath.item].title
let t2 : String = currentItems[indexPath.item].yearRatingGenres()
cell.lbTitle.text = t1
cell.lbYRG.text = t2
cell.tv.text = currentItems[indexPath.item].plot
var strI : String = "https://image.tmdb.org/t/p/w342/"
strI = strI + currentItems[indexPath.item].iPath
cell.iv.setImageUsingFullHttpLink(thisPath: strI)
if currentItems[indexPath.item].isCastLoaded == true
{
PopulateCVCellStackView(scrollView: cell.scrollView,
stackView: cell.stackView,
maximum: 20, width: 120, height: 180,
child: currentItems[indexPath.item].casts )
}
// ===================================================
// StackView Content
func PopulateBannerStackView( stackView: UIStackView,
maximum: Int,
width: CGFloat,
height: CGFloat,
child: [MovieTvObject] )
{
stackView.translatesAutoresizingMaskIntoConstraints = false
let minimum : Int = Int( min( maximum, child.count) )
guard minimum GT 0 else { return }
for idx in 0...(minimum - 1)
{
let iv : MyCurrentUIImageView = MyCurrentUIImageView.init(frame: CGRect.init(x: 0, y: 0, width: width, height: height))
iv.setImageAsTmdbW92(thisPath: child[idx].iPath )
iv.widthAnchor.constraint(equalToConstant: width).isActive = true
iv.heightAnchor.constraint(equalToConstant: height).isActive = true
iv.myParent = self
iv.contentIndex = idx
iv.titleID = child[idx].id
iv.isTV = child[idx].isTv
stackView.addArrangedSubview( iv )
}
self.topScrollView.contentSize = CGSize(width: CGFloat( minimum ) * (width + 6.0), height: height)
} // end PopulateStackView
==================================================================
func PopulateCVCellStackView( scrollView: UIScrollView,
stackView: UIStackView,
maximum: Int,
width: CGFloat,
height: CGFloat,
child: [ CastOrCrew] )
{
stackView.clearStackViewContent()
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.spacing = 6
let minimum : Int = Int( min( maximum, child.count) )
guard minimum GT 0 else { return }
for idx in 0...(minimum - 1)
{
let iv : MyCurrentUIImageView = MyCurrentUIImageView.init(frame: CGRect.init(x: 0, y: 0, width: width, height: height))
iv.setImageAsTmdbW92(thisPath: child[idx].picPath )
iv.widthAnchor.constraint(equalToConstant: width).isActive = true
iv.heightAnchor.constraint(equalToConstant: height).isActive = true
iv.myParent = self
iv.contentIndex = -1
iv.titleID = child[idx].id
iv.myName = child[idx].name + " ( " + child[idx].character + " )"
stackView.addArrangedSubview( iv )
}
scrollView.contentSize = CGSize(width: CGFloat( minimum ) * (width + 6.0), height: height)
} // end PopulateStackView