我是iOS编程的新手。我想在UIbutton
上发送通知(例如,在其角落顶部显示点击次数),很快它会通知UIButton
上的某些计数。
有可能吗?请提供一些想法或一些简短的代码,我该怎么做。
答案 0 :(得分:0)
在头文件中添加
{
IBOutlet UIButton *counterbutton;
}
-(IBAction)pushed:(id)sender;
<。>在.m文件中
int count;
-(IBAction)pushed:(id)sender
{
count = count + 1;
counterbutton.text = [NSString stringWithFormat:@"count is %i",count];
}
在界面构建器中,将按钮连接到IBAction和IBOutlet的视图控制器。
答案 1 :(得分:0)
Flex_Addicted分享链接在我的问题中我想在这里分享更加明显。在该示例中显示了我所问的确切内容,只需在项目中添加h和m文件即可。 How can I add a badge to a standard UIButton?