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

Fixes #12 by removing specific constraint code #23

Merged
merged 1 commit into from Sep 8, 2016

Conversation

m-revetria
Copy link
Member

Fixes issue #12.

The crash is caused because ActionCell is changing the priority from some constraints from Required to Optional and viceversa when they are already installed. This can happen when the setup method is called twice, and the second time passing a null image. These constraints control how the cell's title label is positioned taking into account if the cell has or not an image.

I just removed these constraint from the base class ActionCell instead of trying to change the constraints properties in some way. I opted for removing them because they add specific dependent code on how the cell's UI is designed and should be out of the scope of this class. This way we are avoiding coupling XLActionController base code with specific actions' UI code.

To see how this can be implemented, developers can take a look to TwitterCell

Note: this is a breaking change. If this PR is merged then, apps that are using these constraint it will crash with the exception "this class is not key value coding-compliant for the key..."

2016-09-05 14:44:22.837 Example[6518:267146] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Example.YoutubeCell 0x7fc469e62320> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key actionTitleLabelConstraintToContainer.'

super.setup(title, detail: detail, image: image)

if let _ = image {
imageViewWidthConstraint.constant = 36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imageViewWidthConstraint.constant = image != nil ? 36 : 0

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

Successfully merging this pull request may close these issues.

None yet

2 participants