FSPagerView
FSPagerView copied to clipboard
FSPagerView create custom cell
My cell in FSPagerView is not just an image view and text , actually my cell should have an image view , 3 label and 2 button in it. i create it base on structure in Readme and issues but it return error : Unknown class _TtC19viewPagerCustomCell19viewPagerCustomCell in Interface Builder file. class viewPagerCustomCell : FSPagerViewCell { ...... }
@IBOutlet weak var PagerView: FSPagerView!{ didSet { self.PagerView.register(UINib(nibName: "viewPagerCustomCell", bundle: nil), forCellWithReuseIdentifier: "cell")// error occur } }
public func numberOfItems(in pagerView: FSPagerView) -> Int { self.PageControl.numberOfPages = 5 return 5 }
func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell { let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) as! viewPagerCustomCell return cell }
and in design I create a UIView and subclass it FSPagerView
@nadia-am have you resolve this. Please share the solution.
@Satishphogat1 no i didnt :(
I don't know you already solved this problem but I reached here somehow and here is what I did.
-
Create xib file.
-
From xib, Make one view and subclass it FSPagerViewCell.
-
Comeback to your storyboard, Add empty UIView and subclass it FSPagerView.
-
Connect FSPagerView to source file and add like under. @IBOutlet weak var pagerV: FSPagerView! { didSet { self.pagerV.register(UINib(nibName:"<NIB FILE NAME>", bundle: Bundle.main), forCellWithReuseIdentifier: "cell") } }
-
Then you can see your cell from FSPagerView.
@CheeseStick can you share a demo code. Can't seem to figure it out.
@gurpreetsinghgulati13 Just uploaded a sample demo test project for what I did. It's bit long times ago so I simply copied and paste codes from old project.
https://github.com/CheeseStick/FSPagerViewCellTest
Side note for all Obj-C users: unfortunately subclassing a Swift class in Obj-C is not supported, therefore a custom FSPagerViewCell in an Obj-C project is not possible.
Xcode error message:
Cannot subclass a class that was declared with the 'objc_subclassing_restricted' attribute
I'm new to iOS development. Can you share your code?
@gurpreetsinghgulati13 Just uploaded a sample demo test project for what I did. It's bit long times ago so I simply copied and paste codes from old project.
https://github.com/CheeseStick/FSPagerViewCellTest
Please share the correct code link
https://github.com/CheeseStick/FSPagerViewCellTest
https://github.com/CheeseStick/FSPagerViewCellTest Or just open the profile of @CheeseStick and search in repositories
FSPager has a function to register nib, so you can create custom nib cell and register it