Open jonnyro23 opened 8 years ago
view -> _view have a try
what is the intended use case here? (apologies for late response)
@cwRichardKim , when using UIBarButtonItem's init method initWithTitle:style:target:action:
will cause this issue, if create a UIBarButtonItem with customView, it work well.
not sure i understand, but can i close this issue?
Have the same problem
iOS Custom Badge, Support UIView, UITabBarItem, UIBarButtonItem ,Support Objective-C/Swift : https://github.com/jkpang/PPBadgeView have a try
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]; });
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!
[barButtonItem valueForKey:@"view"]
sometimes returns nil and hub not showing up