RKNotificationHub icon indicating copy to clipboard operation
RKNotificationHub copied to clipboard

[barButtonItem valueForKey:@"view"] returns nil

Open jonnyro23 opened this issue 8 years ago • 8 comments

[barButtonItem valueForKey:@"view"]

sometimes returns nil and hub not showing up

jonnyro23 avatar Jul 19 '16 07:07 jonnyro23

view -> _view have a try

huangboju avatar Jul 28 '16 09:07 huangboju

what is the intended use case here? (apologies for late response)

cwRichardKim avatar Sep 20 '16 04:09 cwRichardKim

@cwRichardKim , when using UIBarButtonItem's init method initWithTitle:style:target:action: will cause this issue, if create a UIBarButtonItem with customView, it work well.

marcuswu0814 avatar Oct 18 '16 11:10 marcuswu0814

not sure i understand, but can i close this issue?

cwRichardKim avatar Oct 18 '16 14:10 cwRichardKim

Have the same problem

Lasithih avatar May 31 '17 07:05 Lasithih

iOS Custom Badge, Support UIView, UITabBarItem, UIBarButtonItem ,Support Objective-C/Swift : https://github.com/jkpang/PPBadgeView have a try

jkpang avatar Oct 10 '17 12:10 jkpang

You can use dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ self.rightBarButtonHub = [[RKNotificationHub alloc] initWithBarButtonItem: BarButtonItemm]; });

hanks-hu avatar Jan 04 '18 06:01 hanks-hu

Fixed the issue by switching to customView UIBarButtonItem:

Before:

    var activityViewsBarButtonItem: UIBarButtonItem {
        return UIBarButtonItem(image: UIImage(named: "AlarmIcon"), style: .plain, target: self, action: #selector(BaseTabBarController.activityViewsBarButtonItemPressed(_:)))
    }

After:

    var activityViewsBarButtonItem: UIBarButtonItem {
        let button = UIButton(type: .system)
        button.setImage(UIImage(named: "AlarmIcon"), for: .normal)
        button.frame = CGRect(x: 0, y: 0, width: 35, height: 35)
        button.addTarget(self, action: #selector(BaseTabBarController.activityViewsBarButtonItemPressed(_:)), for: .touchUpInside)
        
        return UIBarButtonItem(customView: button)
    }

And then it worked. I think this was a regression in iOS 11 (unsure). @cwRichardKim hope it helps!

allaire avatar Jan 24 '18 20:01 allaire