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

Random crash due nil init #123

Open
ppamorim opened this issue Mar 8, 2020 · 7 comments
Open

Random crash due nil init #123

ppamorim opened this issue Mar 8, 2020 · 7 comments

Comments

@ppamorim
Copy link

ppamorim commented Mar 8, 2020

Hi, I was testing my app on the simulator and this happened:

Screenshot 2020-03-08 at 00 11 48

Screenshot 2020-03-08 at 00 11 22

Screenshot 2020-03-08 at 00 11 08

To start the showcase it's calling:

let showcase: MaterialShowcase = MaterialShowcase()
showcase.setTargetView(view: button)
showcase.show(completion: { [weak self] in
  //...
}

Version: 0.7.1

@quangctkm9207
Copy link
Collaborator

Do you think that the materialShowcase.show() function was called too early that the target view had not laid out in UI yet?
So, it was null at that time.

@ppamorim
Copy link
Author

ppamorim commented Mar 9, 2020

@quangctkm9207 button has been created and added as subview in the function loadView() by code and materialShowcase.show() was called in the viewDidAppear(_ animated: Bool) method. I know I know, very strange.

@quangctkm9207
Copy link
Collaborator

Yes. It is quite strange because it happened randomly.

@ppamorim
Copy link
Author

@quangctkm9207 I think the only way to sort this out is to rewrite the instances and use UIView? instead of UIView!.

@quangctkm9207
Copy link
Collaborator

That would be a good suggestion.
Based on your tests, how often does the crash occur?

@AlexanderZubkov
Copy link

AlexanderZubkov commented Mar 23, 2020

/// Sets a UITableViewCell as target
@objc public func setTargetView(tableViewCell: UITableViewCell) {
    targetView = tableViewCell.contentView
    // for tableViewCell, we do not need target holder (circle view)
    // therefore, set its radius = 0
    targetHolderRadius = 0
}

/// Sets a UICollectionViewCell as target
@objc public func setTargetView(collectionViewCell: UICollectionViewCell) {
    targetView = collectionViewCell
    // for collectionViewCell, we do not need target holder (circle view)
    // therefore, set its radius = 0
    targetHolderRadius = 0
}

@geclick
Copy link

geclick commented Jun 16, 2020

Hey, i wanted to show the showcase on a UIBarButtonItem and i ran into this crash. The reason is here:

if let view = (barButtonItem.value(forKey: "view") as? UIView)?.subviews.first {
targetView = view
}

view cannot be casted to UIView so this fails and targetView never get initialized. I solved this by setting a custom view(UIButton) to the UIBarButtonItem

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

No branches or pull requests

4 participants