【iOS】按钮点击弹窗
来源:互联网 发布:小米6陶瓷尊享版 知乎 编辑:程序博客网 时间:2024/06/05 11:14
拖入一个Round Rect Button,并将Button的文字修改成“点击弹窗”
将ViewController.h修改为如下代码,实则在ViewController.h中添加了一行-(IBAction)messageBoxShow;,注册messageBoxShow这个函数。类似于C语言使用函数之前需要在头文件声明这个函数头。
//// ViewController.h// MessageBox//// Created by pc on 17-5-13.// Copyright (c) 2017年 pc. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController-(IBAction)messageBoxShow;@end将ViewController.m修改为如下的代码,实则添加-(IBAction)messageBoxShow函数,并完成这个函数的内容。
//// ViewController.m// MessageBox//// Created by pc on 17-5-13.// Copyright (c) 2017年 pc. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}-(IBAction)messageBoxShow{ UIAlertView *uiAlertView=[[UIAlertView alloc]initWithTitle:@"弹窗标题栏"message:@"弹窗消息"delegate:nil cancelButtonTitle:@"确定!" otherButtonTitles:nil]; [uiAlertView show]; }@end回到MainStoryboard.storyboard,单击按钮之后,按着Ctrl出现蓝色箭头,将其拖到View Controller,松开鼠标和Ctrl,指定点击事件。
之后会弹出菜单,选择Sent Events下面的messageBoxShow函数。
点击运行之后,点击按钮则可以弹窗,如下图所示。
0 0
- 【iOS】按钮点击弹窗
- IOS 按钮点击 跳转
- ios防止按钮多次点击
- iOS 点击按钮实现复制
- iOS---点击tableviewcell中的按钮
- iOS点击按钮高亮
- iOS-点击按钮,改变图片
- iOS 按钮点击状态保存
- iOS按钮点击效果消失
- iOS点击按钮隐藏状态栏
- iOS-增大按钮点击范围
- IOS 按钮点击发光效果
- iOS创建浮动按钮,点击按钮“置顶”
- iOS:按钮连续点击 按钮快速点击 如何处理
- 基于按钮点击事件的弹窗
- 点击按钮弹窗(自用,有瑕疵)
- iOS 禁用多按钮同时点击效果
- iOS之点击按钮切换背景图片
- android移除数据
- (回溯法)LeetCode#79. Word Search
- Java中调用Oracle存储过程及存储函数
- photoshop 快捷键操作 and 基本操作
- TensorFlow+MNIST实例讲解
- 【iOS】按钮点击弹窗
- 基于CAS4.0.0的单点登陆
- 如何在Intellij Idea中使用GitHub
- Android极光推送自定义消息
- Java中的值传递和“引用传递”
- 【机器学习】【数据处理】numpy.random.RandomState函数用法
- P2911 [USACO08OCT]牛骨头Bovine Bones(c++)
- 2016 年 7 个顶级 JavaScript 框架
- Linux中CodeBlocks运行程序无法启动终端的原因及解决办法