【问题标题】:How can I create notifications on UIButton如何在 UIButton 上创建通知
【发布时间】:2012-06-09 14:49:19
【问题描述】:

我是 iOS 编程的新手。我想在UIbutton 上发布通知(例如在其角落顶部显示点击次数),不久它会通知一些在UIButton 上的计数。

有可能吗?请给出一些想法或一些简短的代码,我该怎么做。

【问题讨论】:

标签: iphone ios xcode notifications uibutton


【解决方案1】:

在头文件中添加

  {
  IBOutlet UIButton *counterbutton;
  }

  -(IBAction)pushed:(id)sender;

在 .m 文件中 整数;

 -(IBAction)pushed:(id)sender
 {
    count = count + 1;
    counterbutton.text = [NSString stringWithFormat:@"count is %i",count];
 }

在界面构建器中,将按钮连接到 IBAction 和 IBOutlet 的视图控制器。

【讨论】:

    【解决方案2】:

    Flex_Addicted 在我的问题中分享该链接我想在这里分享更容易辨别。在该示例中,准确显示了我的要求,只需在项目中添加 h 和 m 文件就很容易了。 How can I add a badge to a standard UIButton?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-29
      • 2022-01-03
      • 1970-01-01
      • 2021-03-20
      • 2020-09-25
      • 1970-01-01
      • 2012-10-10
      • 2014-09-24
      相关资源
      最近更新 更多