IOS控件:分歧解决其(UILabel 和 IBAction)
ios 解决 控件 UILabel
2023-09-14 09:00:23 时间
#import <UIKit/UIKit.h> @interface demo7_dayViewController : UIViewController { // 用来显示程序结果 IBOutlet UILabel *result; } // 属性声明 @property(nonatomic, retain) UILabel *result; // 同意或反对的值 -(IBAction) agreeDisagree; // 左中右的值 -(IBAction) leftCenterRight; // 从1-100其中之一的值 -(IBAction) oneToHundred; // 左轮枪的值 -(IBAction) ressianRoulette; @end
#import "demo7_dayViewController.h" @interface demo7_dayViewController () @end @implementation demo7_dayViewController // 本指令告诉编译器去合成今天方法所需的结果控件的存储器方法 @synthesize result; /** 同意或反对的值 */ -(IBAction) agreeDisagree{ // 创建一个取得整数的变量,rund%2为变量返回"0"或"1",随机二选一整数 int rNumber = rand() % 2; switch (rNumber) { case 0: result.text = @"同意"; break; case 1: result.text = @"反对"; break; default: break; } } /** 左中右的值 */ -(IBAction) leftCenterRight{ int rNumber = rand() % 3; switch (rNumber) { case 0: result.text = @"左"; break; case 1: result.text = @"中"; break; case 2: result.text = @"右"; break; default: break; } } /** 从1-100其中之一的值 */ -(IBAction) oneToHundred{ int rNumber = rand() % 100; result.text = [NSString stringWithFormat:@"%d", rNumber]; } /** 左轮枪的值 */ -(IBAction) ressianRoulette{ int rNumber = rand() % 6; switch (rNumber) { case 0: result.text = @"砰!!!"; break; default: result.text = @"没事了。。。"; break; } } - (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. } /** 执行内存进行清理工作 */ -(void)dealloc { [result release]; [super dealloc]; } @end
相关文章
- iOS工程中的info.plist文件的完整研究
- 移动端 ios 长按复制兼容方案
- iOS/OS X 内存管理(二):借助工具解决内存问题
- iOS设计模式 - 代理
- iOS中的动画
- 整理常用的iOS第三方资源
- IOS之KVC和KVO(未完待续)
- 【IOS-COCOS2D游戏开发之七】在COCOS2D中添加/删除系统组件,并解决VIEW设置透明会影响VIEW中的其他组件的问题!【11月28日更新解决添加组件COCOS2D动画停止播放的BUG】
- 【IOS-COCOS2D游戏开发之十】添加粒子系统特效并解决粒子特效与LAYER之间的坐标问题;
- iOS中 蓝牙2.0详解/ios蓝牙设备详解
- iOS网络编程-解决iCloud文档存储过程中文档冲突问题
- ios上视频与音乐合成后出现播放兼容问题的解决方法
- 关于 Safari back 按钮在 iOS 16 不能按照期望工作的问题分析
- ios swift UITabBarController present dismiss
- ios swift5 Codable 本地存储(存取) 字典转模型
- iOS init 指定初始化函数
- iOS:runtime 消息转发 Method_Swizzling 动态添加方法 动态方法解析
- ios跳到根控制器(swift 附跳到指定控制器的连接)self.navigationController.viewControllers UINavigationController
- 创建自签名的 SSL 证书以及 添加自签CA到 电脑或者IOS, debian 添加 信任的 CA
- ios AFNetworking 有用篇
- 解决输入法遮挡--ios手机