Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update DropDown #24

Closed
J-Arji opened this issue Jun 17, 2016 · 16 comments
Closed

update DropDown #24

J-Arji opened this issue Jun 17, 2016 · 16 comments

Comments

@J-Arji
Copy link

J-Arji commented Jun 17, 2016

hi
i update DropDown from 1 to 1.5 but when running program app not working and error
"DropDown.DropDown.anchorView.setter : weak DropDown.AnchorView?", referenced from:

Undefined symbols for architecture x86_64:
  "DropDown.DropDown.anchorView.setter : weak DropDown.AnchorView?", referenced from:
      balen.AircraftSearch.viewDidLoad () -> () in AircraftSearch.o
  "protocol witness table for __ObjC.UIView : DropDown.AnchorView in DropDown", referenced from:
      balen.AircraftSearch.viewDidLoad () -> () in AircraftSearch.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@kevin-hirsch
Copy link
Collaborator

kevin-hirsch commented Jun 17, 2016

Hello @J-Arji, Thanks for using this library! :)

Can you show the code where you are using the DropDown?
How have you imported this library, manually, via Cocoapods or Carthage?
Are you using DropDown in Objective-C ?

@J-Arji
Copy link
Author

J-Arji commented Jun 17, 2016

i import with cocoapods an using in swift

code:

      dropDown.dataSource = [
            "Car",
            "Motorcycle",
            "Van",
            "Truck",
            "Bus",
            "Bicycle",
            "Feet"
        ]

            dropDown.selectionAction = { [unowned self] (index, item) in
            self.actionButton.setTitle(item, forState: .Normal)
                let lit = item
                print(lit)
        }

        dropDown.direction = .Bottom
        dropDown.anchorView = actionButton
        dropDown.bottomOffset = CGPoint(x: 0, y:actionButton.bounds.height)
        // returns a String?




    }


    @IBAction func ActionTypeAir(sender: AnyObject) {

        if dropDown.hidden {
            dropDown.show()
        } else {
            dropDown.hide()
        }


@kevin-hirsch
Copy link
Collaborator

Thanks for the follow-up! 👍

So the only line that's causing problem seems to be

dropDown.anchorView = actionButton

Did you try compiling with this line in comment?

@markedwardmurray
Copy link
Contributor

markedwardmurray commented Jun 17, 2016

Hey @kevin-hirsch I just updated to v1.0 (congrats on the full release) and using your pod from an Objective-C view controller I experience this issue also. It appears that the anchorView property is not visible to Objective-C. I suspect because it is an Optional of a non-Objective-C type: http://stackoverflow.com/questions/26366082/cannot-access-property-of-swift-type-from-objective-c

@markedwardmurray
Copy link
Contributor

Adding @objc before the protocol definition in line 18 allows it to build:

@objc public protocol AnchorView: class {

    var plainView: UIView { get }

}

@kevin-hirsch
Copy link
Collaborator

Hello @markedwardmurray, thanks! :)
anchorView has the type:

public protocol AnchorView: class {
    var plainView: UIView { get }
}

Did you try adding an @objc above the protocol?

@kevin-hirsch
Copy link
Collaborator

Ok, perfect! I'll add this now 👍

@markedwardmurray
Copy link
Contributor

Yup, that's literally all it needs! I did have to avoid using the .bounds property on the anchorView from my view controller since it's now a type id, but that's no big deal.

@kevin-hirsch
Copy link
Collaborator

You can access the view through anchorView.plainView property, so for bounds, just do anchorView.plainView.bounds 😉

@markedwardmurray
Copy link
Contributor

oh nice! thanks for the tip on that :)

@kevin-hirsch
Copy link
Collaborator

Done in 9d734e5. I will create a new version 1.0.1 for CocoaPods and Carthage.

@kevin-hirsch
Copy link
Collaborator

Actually, the reason I now use an AnchorView and not a UIView anymore is that I wanted to support UIBarButtonItems that are not UIView subclassed. So I implemented:

 extension UIView: AnchorView {
    public var plainView: UIView {
        return self
    }
 }

 extension UIBarButtonItem: AnchorView { 
    public var plainView: UIView {
        return valueForKey("view") as! UIView
    }
 }

So anchorView.plainView is the same as using anchorView before 1.0 🙃

@kevin-hirsch
Copy link
Collaborator

Version 1.0.1 available on CocoaPods and Carthage! 🎉

@J-Arji Can you confirm that you don't have the issue anymore?
I leave this issue open until your confirmation.

@J-Arji
Copy link
Author

J-Arji commented Jun 17, 2016

thanks @kevin-hirsch :) #

@GZaccaroni
Copy link

GZaccaroni commented Jan 1, 2018

 extension UIBarButtonItem: AnchorView { 
    public var plainView: UIView {
        return valueForKey("view") as! UIView
    }
 }

doesn't work anymore in iOS 11.
Access to a private API can lead to a app being refused during the apple app store review process.
My suggestion is to delete the extension @kevin-hirsch

@mekalasiva
Copy link

I AM Facing the issue with Large Text in the DropDown Can u please share how to handle.

EX:

DropDown.dataSource = ["asfasdfadfhsfasfsadfsadfdsafgafskhfhskafhfahahfshfkj"]

DropDown not showing the Anchor width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants