Hot questions for Using Eureka in uitableview

Question:

All --

I’ve just started using Eureka forms builder on an iOS project, and it has a lot of wonderful features. It’s very nicely done.

However, I eventually realized that there doesn’t seem to be a good way to customize the Height of any given row. [Interestingly, in the Example app, many different rows demonstrating different features are all the same height.]

Granted I can override heightForRowAtIndexPath (which I’ve tried) ... but rows (and indexes) get added dynamically when they’re hidden and unhidden, which makes things more complicated.

Before getting into even more workarounds for this: Is there a simpler / more elegant way of adjusting individual row heights within the framework itself?

I’d like to set the height of any given row within the definition of each Row, or its .cellSetup, .cellUpdate or similar closures.

Or even better, is there a straightforward way to have the UITableView respect the ‘intrinsic’ dimensions of only those labels which are used, according to the actual font sizes used? In other words, if the font in a given row is smaller, that row height should be correspondingly less.

Your help very much appreciated at this point.

Thank you in advance!


Answer:

try with this

 <<< TextRow().cellSetup({ (cell, row) in
                cell.height = ({return 10})
            })

this will change the height, I Hope this helps you

Question:

Maybe it's a useless question but, i'm trying to make a "for loop" with labelRow, but it don't do what i want .. :/

i wanna the same things like the example project of Eureka with SegmentedRow, but in segment i want to do a loop for rows.

Can someone guide me ?

thanks !!

ps:

thats what i try in view did load:

 self.form = Section()
        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
        }

        +++ Section(){
            $0.tag = "past_s"
            $0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
    }

    for it in self.past {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }

    self.form +++= Section(){
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }

    for it in self.waiting {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }

    self.form +++= Section(){
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }

    for it in self.future {
        self.form.last! <<< TextRow() { row in
            row.title = "Which is your favourite soccer player?"
        }
    }

and thats what i'm waiting :)

self.form = Section()
        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
        }

        +++ Section(){
            $0.tag = "past_s"
            $0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
        }

        <<< LabelRow() { row in
            row.title = "1"
        }

        <<< LabelRow() { row in
            row.title = "temp"
        }

        +++ Section(){
            $0.tag = "waiting_s"
            $0.hidden = "$segments != 'En cours'"
        }

        <<< LabelRow() { row in
            row.title = "2"
        }

        <<< LabelRow() { row in
            row.title = "temp"
        }

        +++ Section(){
            $0.tag = "futur_s"
            $0.hidden = "$segments != 'Futures'"
        }

        <<< LabelRow() { row in
            row.title = "3"
        }

        <<< LabelRow() { row in
            row.title = "temp"
    }

i ve tried that too (and a lot of others ways):

        form +++ Section()
    form.last! <<< SegmentedRow<String>("segments"){
        $0.options = ["Passées", "En cours", "Futures"]
        $0.value = "En cours"
    }

    form +++= Section(){
        $0.tag = "past_s"
        $0.hidden = "$segments != 'Passées'"
    }

    for past in self.past {
        form.last! <<< LabelRow() { row in
            row.title = "1"
        }
    }

and try this too :

        form = Section()
        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
    }

    form +++ self.pastSection!
    form +++ self.waitingSection!
    form +++ self.futurSection!

    self.pastSection = Section("past_s") {
        $0.tag = "past_s"
        $0.hidden = "$segments != 'Passées'"
    }

    self.waitingSection = Section("waiting_s") {
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }

    self.futurSection = Section("futur_s") {
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }

    for past in self.past {
        self.pastSection!
            <<< LabelRow() {
                $0.title = "test"
        }
    }

    for waiting in self.waiting {
        self.waitingSection!
            <<< LabelRow() {
                $0.title = "test"
        }
    }

    for futur in self.future {
        self.futurSection!
            <<< LabelRow() {
                $0.title = "test"
        }
    }

    form +++ self.pastSection!
    form +++ self.waitingSection!
    form +++ self.futurSection!

but i've got an error like this photo of error


Answer:

finally i found the answer !

form.delegate = nil
    form.removeAll()

    form +++= Section("DuplicateCounter") { row in row.tag = "DuplicateCounter" }

        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
    }

    self.pastSection = Section("past_s") {
        $0.tag = "past_s"
        $0.hidden = "$segments != 'Passées'"
    }

    self.waitingSection = Section("waiting_s") {
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }

    self.futurSection = Section("futur_s") {
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }

    form +++ self.pastSection!
    form +++ self.waitingSection!
    form +++ self.futurSection!

    for past in self.past {
        self.pastSection!
            <<< LabelRow("\(past.id)") {
                $0.title = "test"
        }
    }

    for waiting in self.waiting {
        self.waitingSection!
            <<< LabelRow("\(waiting.id)") {
                $0.title = "test"
        }
    }

    for futur in self.future {
        self.futurSection!
            <<< LabelRow("\(futur.id)") {
                $0.title = "test"
        }
    }

thanks for reading :) see ya

Question:

i have three UIImageView on a single Cell when i click on any of the UIImageView on the cell i want to detect which one was clicked on onCellSelection, without placing a UITapGestureRecognizer on each UIImageview

func SocialViewRow(address: SocialMedia)-> ViewRow<SocialMediaViewFile> {

let viewRow = ViewRow<SocialMediaViewFile>() { (row) in

    row.tag = UUID.init().uuidString
    }
    .cellSetup { (cell, row) in
        //  Construct the view
        let bundle = Bundle.main
        let nib = UINib(nibName: "SocialMediaView", bundle: bundle)

        cell.view = nib.instantiate(withOwner: self, options: nil)[0] as? SocialMediaViewFile
        cell.view?.backgroundColor = cell.backgroundColor
        cell.height =  { 50 }
        print("LINK \(address.facebook?[0] ?? "")")

        cell.view?.iconOne.tag = 90090

        //self.itemDetails.activeURL = address

        let openFace = UITapGestureRecognizer(target: self, action: #selector(QuickItemDetailVC.openFace))
        let openT = UITapGestureRecognizer(target: self, action: #selector(QuickItemDetailVC.openTwit))
        let you = UITapGestureRecognizer(target: self, action: #selector(QuickItemDetailVC.openYouYub))

         cell.view?.iconOne.addGestureRecognizer(openFace)

         cell.view?.iconTwo.addGestureRecognizer(openT)
         cell.view?.iconThree.addGestureRecognizer(you)



        cell.frame.insetBy(dx: 5.0, dy: 5.0)
        cell.selectionStyle = .none

    }.onCellSelection() {cell,row in

     //example   
    //print(iconTwo was clicked)


}


return viewRow
}

Answer:

Using UITapGestureRecogniser (or UIButton) would be a better approach. These classes intended for tasks like this.

If you still want to use different approach, add method to your cell subclass (replace imageView1, imageView2, imageView3 with your own properties)

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  guard let touch = touches.first else { return }
  let point = touch.location(in: view)
  if imageView1.frame.containsPoint(point) {
    // code for 1st image view
  } else if imageView2.frame.containsPoint(point) {
    // code for 2nd image view
  } else if imageView3.frame.containsPoint(point) {
    // code for 3rd image view
  }
}

Docs: