kcandr / IQLabelView

IQLabelView is used to add text overlay and resize and rotate it with single finger.
MIT License
112 stars 32 forks source link

Unrecognized selector sent to instance #7

Closed instaqwe closed 9 years ago

instaqwe commented 9 years ago

I keep getting unrecognized selector sent to instance, and I can't figure out why. Every time I try to resize the IQLabelView, I get the error. Is the control bugged or am I doing something completely wrong?

var aLabel = UITextField(frame: CGRectMake(0, 0, 50, 50))
        aLabel.clipsToBounds = true
        aLabel.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin|UIViewAutoresizing.FlexibleLeftMargin|UIViewAutoresizing.FlexibleRightMargin
        aLabel.text = "jalla"  //caption.text
        aLabel.textColor = UIColor.whiteColor()
        aLabel.sizeToFit()

        var bigCaption = IQLabelView(frame: CGRectMake(100, 100, 60, 50))
        bigCaption.autoresizingMask = UIViewAutoresizing.FlexibleHeight|UIViewAutoresizing.FlexibleWidth
        bigCaption.delegate = self
        bigCaption.showContentShadow = false
        bigCaption.setTextField(aLabel)
        bigCaption.fontName = "Baskerville-BoldItalic"
        bigCaption.fontSize = 21.0
        bigCaption.sizeToFit()
        self.view.addSubview(bigCaption)
        bigCaption.becomeFirstResponder()

        currentlyEditingLabel = bigCaption

//Biglabel functions

func touchOutside(touchGesture: UITapGestureRecognizer){
    println("touch outside")
}
func labelViewDidClose(label: IQLabelView!) {
    println("label close")
}
func labelViewDidBeginEditing(label: IQLabelView!) {
    println("didbeginediting")
}
func labelViewDidStartEditing(label: IQLabelView!) {
    currentlyEditingLabel = label;

}
func labelViewDidShowEditingHandles(label: IQLabelView!) {
    currentlyEditingLabel = label
}
func labelViewDidHideEditingHandles(label: IQLabelView!) {
    currentlyEditingLabel = nil
}

Full error: *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OS_dispatch_semaphore copyWithZone:]: unrecognized selector sent to instance 0x14fc3c30'

kcandr commented 9 years ago

@instaqwe I'm no expert in Swift but apparently there are problems with fontName property. You can replace assign to retain or strong and everything worked

instaqwe commented 9 years ago

Thanks, that seems to working!