Git Product home page Git Product logo

Comments (27)

jasvindersingh-evon avatar jasvindersingh-evon commented on July 19, 2024

Have you added the button on Table View or on a cell?

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@jasvindersingh-evon I set in the tableView, not in the cell. If it's in the cell, the button will located in the tableView cell, but this is not right?

let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 56 - 80, width: 56, height: 56)
        let bottomRightButton = createFloatButton(floatingFrame, .Up)
        self.view.addSubview(bottomRightButton)

This is my code for locating in the tableView. I've added the subView into the tableView. just wondering why it's not stick to the position, it will moves when I'm scrolling.

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo If you want to stick to the position, you should use UIWindow or other.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt Any example of UIWindow to make this button stick at the fixed position?

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo Otherwise, you can also do hierarchy views as follows.
UIView
-- LiquidFloatingActionButton
-- UITableView

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt I'm sorry for telling you that I'm still a beginner in iOS programming, could you give me some clue regarding the similar code to me?

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo OK. This is example!!
https://gist.github.com/yoavlt/393a0bce0536e926b01d

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt Thanks dude, I'm appreciate, I will try to do it now see whether I got it or not 👍 will support your project always!

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt May I know what this line of code means?

tableView.snp_makeConstraints { make in
            make.width.height.top.left.equalTo(self.view)
        }

As I know, tableView don't have a function called snp_makeConstraints

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo It's SnapKit's extension. You can also use AutoLayout.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

Opps, I knew that, it's SnapKit extension hahaha I just found out that. Thank you

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt I failed to do it.

make.width.height.top.left.equalTo(self.view)

There's an error on this line.
fatal error: unexpectedly found nil while unwrapping an Optional value
I've no idea why there's an optional value at this line, that's quite weird.

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo It's totally odd. 😭

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt I got a clue from this Question.
http://stackoverflow.com/questions/13663230/ios-add-subview-with-a-fix-position-on-screen
We can try to do it by this way. Let's try.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt Are you manage to do it with the scrollViewDidScroll method?

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo No, I didn't. It works for my environment.

from liquidfloatingactionbutton.

jasvindersingh-evon avatar jasvindersingh-evon commented on July 19, 2024

@jefferyleo: self.view is your tableview I guess, And adding it on self.view means you are adding it on tableview. So whenever the UITableView will scroll, the button will scroll with it. If you want to add it. Add it on self.view considering self.view should not be a TableView. Please attach the XIB/storyboard screenshot with outline hierarchy displayed.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@jasvindersingh-evon then do you know how do I stick to the scrollView, since the scrollView has also a delegate from the tableViewController.

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo I know. You should use UIViewController instead of UITableViewController.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt But..I want to list all the news in a tableView instead of ViewController, that's why I have to use UITableViewController in necessary. :(

from liquidfloatingactionbutton.

jasvindersingh-evon avatar jasvindersingh-evon commented on July 19, 2024

Understood. Do one thing. Delete the UITableViewController and take a new UIViewController. In that View controller add a UITableView. Then add the button on that view controller. Set Delegate and data source of UITableView to File's Owner. And everything will work. Let me know if this doesn't works for you.

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo I agree with @jasvindersingh-evon's solution.

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@jasvindersingh-evon Okay, I'll try that later, will get back to you soon, I fixing another problem first. :(

from liquidfloatingactionbutton.

jefferyleo avatar jefferyleo commented on July 19, 2024

@yoavlt @jasvindersingh-evon Okay, good news here! I did it hahaha Thanks a lot dude, appreciated. 👍

from liquidfloatingactionbutton.

yoavlt avatar yoavlt commented on July 19, 2024

@jefferyleo Congrats! 👍

from liquidfloatingactionbutton.

harry-77 avatar harry-77 commented on July 19, 2024

@jefferyleo How you reorder these cell ?

from liquidfloatingactionbutton.

harry-77 avatar harry-77 commented on July 19, 2024

//below implementation is for adding floating button while subclassing UITableViewController

var addMoreImageBtn : UIButton?

override func viewDidLoad() {
super.viewDidLoad()

    addMoreImageBtn = UIButton(type: .Custom)
    addMoreImageBtn?.setImage(UIImage(named: "Add.png"), forState: .Normal)
    addMoreImageBtn?.frame = CGRectMake(0, self.view.bounds.size.height - 100, 55, 55)

    addMoreImageBtn?.center = CGPointMake(self.view.bounds.width - 100 , self.view.bounds.size.height - 100)

    addMoreImageBtn?.addTarget(self, action: "addButtonPressed:", forControlEvents: .TouchUpInside)

    self.view.addSubview(addMoreImageBtn!)
}

override func scrollViewDidScroll(scrollView: UIScrollView) {
addMoreImageBtn?.frame.origin.y = self.view.bounds.size.height - 100 + scrollView.contentOffset.y

    self.view.addSubview(addMoreImageBtn!)
    self.view.bringSubviewToFront(addMoreImageBtn!)

}

from liquidfloatingactionbutton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.