通知中心注册被删除(Notification hub registrations getting deleted)
我们正在使用通知中心向Android设备发送通知。
虽然事情还不错,但我意识到了一些事情。 一段时间后,注册似乎被清除(其中一些)。
它们可能是无效的注册,但它看起来确实如此,azure在幕后做了一些事情来删除它们。
是否有任何建议,azure不时删除无效注册? 还是我想念的东西。
We are using notification hub to send notification to android devices.
Although things are working okay, I realized something. Registrations appear to get cleared up (some of them) after some time.
They may be invalid registrations, but it definitely looks like, azure does something behind the scenes to remove those.
Is there anything to suggest, azure deletes invalid registrations time to time? or is it something I am missing.
原文:https://stackoverflow.com/questions/44000597
最满意答案
有一个更好的方法。
取两个按钮并将它们保存在stackView中并进行必要的设置。
但请确保两个按钮指向相同的动作。因此,用户似乎实际上只有一个按钮。
这是输出。
我刚刚在故事板中做到了这一点。 因为我正在使用stackView所以以编程方式创建和布局非常容易。 我想你可以做到。 :)
要停止闪烁:
使每个按钮类型自定义。
如何只对一个按钮执行一个按钮操作?
看到这个流行的堆栈答案。
这是结果。
I was able to put the two labels and get them highlighted when clicked by creating a
UIButton
other than.custom
(for this example I used.roundedRect
), setting a dummy title, adding subviews to the button title itself and setting their constraints as I wanted to. It works as expected.Code:
class Button: UIView { let button: UIButton let leftLabel = UILabel() let rightLabel = UILabel() init() { button = UIButton(type: .roundedRect) super.init(frame: .zero) createButton() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } func createButton() { self.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false button.topAnchor.constraint(equalTo: self.topAnchor).isActive = true button.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true button.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true button.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true button.backgroundColor = UIColor.cyan button.layer.borderWidth = 0.5 button.layer.borderColor = UIColor.blue.cgColor button.setTitle(" ", for: .normal) if let title = button.titleLabel { title.addSubview(rightLabel) rightLabel.text = "right" rightLabel.translatesAutoresizingMaskIntoConstraints = false rightLabel.topAnchor.constraint(equalTo: title.topAnchor).isActive = true rightLabel.leadingAnchor.constraint(greaterThanOrEqualTo: title.trailingAnchor).isActive = true rightLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true rightLabel.bottomAnchor.constraint(equalTo: title.bottomAnchor).isActive = true title.addSubview(leftLabel) leftLabel.text = "left" leftLabel.translatesAutoresizingMaskIntoConstraints = false leftLabel.topAnchor.constraint(equalTo: title.topAnchor).isActive = true leftLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true leftLabel.trailingAnchor.constraint(lessThanOrEqualTo: title.leadingAnchor).isActive = true leftLabel.bottomAnchor.constraint(equalTo: title.bottomAnchor).isActive = true } button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) } func buttonTapped() { print("button tapped") }
相关问答
更多-
当它的alpha设置为0.0时,UIButton是否被禁用?(Does UIButton become disabled when its alpha is set to 0.0?)[2023-09-26]
根据Apple的 UIView的hitTest:withEvent:方法的文档 : 此方法忽略隐藏的视图对象,禁用用户交互或alpha级别小于0.01。 因此,任何具有低于0.01的alpha的UIView将被触摸事件处理系统忽略,即不会接收触摸。 As per Apple's documentation for UIView's hitTest:withEvent: method: This method ignores view objects that are hidden, that have di ... -
我认为这是文档中的一个错误。 你应该在bugreport.apple.com上提交。 通过一番快速研究,我可以看到的一切都表明,你所看到的是它总是如何表现,而我自己的测试也显示出来。 视图的alpha应用于所有子视图。 也许你需要的是[[UIColor blackColor] colorWithAlphaComponent:0.5]但如果不是,您将需要使视图成为兄弟,而不是一个孩子。 I think this is a bug in the documentation. You should file it ...
-
您正在使用图像视图的图像设置按钮的图像。 您的图片视图的alpha值为0.5,但当然不是您的图片。 而是将图像视图添加为按钮的子视图: [topBtn addSubView:imageTopView]; You are setting the image of the button with the image of your image view. Your image view has an alpha of 0.5, but of course not your image. Instead, ad ...
-
UIButton标签不会更新(UIButton label will not update)[2021-07-27]
当您想要更改按钮标题时,请使用以下内容: UIButton *myButton; // // // [myButton setTitle:@"Incomplete" forState:UIControlStateNormal]; 希望这可以帮助。 When you want the button title to change, use the following: UIButton *myButton; // // // [myButton setTitle:@"Incomplete" forState ... -
如何根据游戏中剩余的玩家数量更新我的标签子视图(how to update my label subviews based on how many player are left in the game)[2022-06-09]
给你的每个explanationLabel标签一个标签,关于你的self.turn 例如, explanationLabel.tag = 1; explanationLabelTwo.tag = 2; explanationLabelThree.tag = 3; . . explanationLabelN.tag = N; 现在,您要调用一个名为hideLabels - (void) hideLabels { explanationLabel.hidden = YES; explanati ... -
总结其他两个答案的评论:子类化和/或添加另一个UIImageView是实现持久,依赖行为的最简单选择。 To conclude the comments on both other answers: subclassing and/or adding another UIImageView is the simplest choice to archieve persistent, reliant behaviour.
-
默认情况下,在动画制作动画时,UIVIew动画不允许用户进行交互。 幸运的是有一个动画选项allowUserInteraction 。 没有更多的信息,但你可以在文档中看到它。 也值得在这里查看所有的选项。 尝试这个: UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [.curveEaseOut, .allowUserInteracti ...
-
有一个更好的方法。 取两个按钮并将它们保存在stackView中并进行必要的设置。 但请确保两个按钮指向相同的动作。因此,用户似乎实际上只有一个按钮。 这是输出。 我刚刚在故事板中做到了这一点。 因为我正在使用stackView所以以编程方式创建和布局非常容易。 我想你可以做到。 :) 要停止闪烁: 使每个按钮类型自定义。 如何只对一个按钮执行一个按钮操作? 看到这个流行的堆栈答案。 这是结果。 I was able to put the two labels and get them highlighte ...
-
干得好: self.view.layer.allowsGroupOpacity = YES; 这适用于所有子视图,子视图的子视图以及所有这些。 来自文档: * The default value of the property is read from the boolean * UIViewGroupOpacity property in the main bundle's Info.plist. If no * value is found in the Info.plist the defa ...
-
Alpha不更新 - UIColor(Alpha Not Updating - UIColor)[2023-02-20]
view.backgroundColor的alpha组件和view.alpha是2个独立的东西。 您似乎在故事板中设置了view.alpha = 0.2 ,因此要更改代码中的Alpha ... @IBAction func test(_ sender: UIButton) { watermarkRows[3].stackView.subviews[20].alpha = 1 } The alpha component of the view.backgroundColor and the view ...