zoonooz / ZFRippleButton

Custom UIButton effect inspired by Google Material Design
MIT License
1.41k stars 110 forks source link

UIViewReportBrokenSuperviewChain iOS 10 crash #23

Closed elprl closed 8 years ago

elprl commented 8 years ago

I'm getting the following error on iOS 10. This is a new error so not seen a lot on Stackoverflow about this: http://stackoverflow.com/questions/39565424/swift-uiviewreportbrokensuperviewchain-cause-by-layer-manipulation

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'View has lost track of its superview, most likely through unsupported use of CALayer API on the view's layer. If this isn't a crash yet, it will be in the near future. Problem view: <UIView: 0x7e70e630; frame = (0 0; 72 205); alpha = 0; layer = <CALayer: 0x7a6521b0>> Expected parent: <ZFRippleButton.ZFRippleButton: 0x7a906fb0; baseClass = UIButton; frame = (528 12; 72 205); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7e7144e0>> Break on UIViewReportBrokenSuperviewChain to debug.'

elprl commented 8 years ago

When I comment out layer.addSublayer(rippleBackgroundView.layer) I get no errors.

All my buttons are added via Interface Builder, so no code. Xcode 8.1 Beta with a Swift3 project.

sravanco commented 8 years ago

@elprl But did the ripple effect exists after removing rippleBackgroundView? I see no more ripple effect after commenting out this statement. All on IB, no code. XCode 8 and Swift3.

sravanco commented 8 years ago

Instead of layer, using view.addSubView(subView) did fix the problem.

rippleBackgroundView.addSubview(rippleView)
self.addSubview(rippleBackgroundView)
elprl commented 8 years ago

Yep, the ripple did stop after commenting out that line. It was just to highlight where the error was occurring. Good to know you fixed it.

kiwo12345 commented 8 years ago

@elprl @sravanco What branch are you using? I could not find any swift 3 branch

sravanco commented 8 years ago

@kiwo12345 Neither I. Its just one file so I quickly adapted to Swift3. No Carthage support so I have to drop the file into my project. I didn't use but did you check this already, https://github.com/zoonooz/ZFRippleButton/pull/21/commits/84df0f39c6d7eb78fcb501b3d074a2fcac30c218

kiwo12345 commented 8 years ago

@sravanco Thanks!

kiwo12345 commented 8 years ago

@sravanco @elprl I dont think you have to add

rippleBackgroundView.addSubview(rippleView)
self.addSubview(rippleBackgroundView) 

If you build the project in Xocde 8.1. Atleast i dont see the problem if I build in 8.1 and test on a device running ios >= 10

vitobellini commented 8 years ago

I was with Xcode 8.0, those two lines of code did the trick. I'll check further with Xcode 8.1

Ing. Vito Bellini

Mobile: (+39) 348 8908593 v.bellini@gmail.com http://www.vitobellini.com

On Wed, Nov 2, 2016 at 3:13 PM, Kevin Thulin notifications@github.com wrote:

@sravanco https://github.com/sravanco @elprl https://github.com/elprl I dont think you have to add

rippleBackgroundView.addSubview(rippleView) self.addSubview(rippleBackgroundView)

If you build the project in Xocde 8.1. Atleast i dont see the problem if I build in 8.1 and test on a device running ios >= 10

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/zoonooz/ZFRippleButton/issues/23#issuecomment-257876107, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKHb9_gDb2eURb3uLgKa3IDCHVfaVJTks5q6JpugaJpZM4KF_Vt .