屏幕快照 2016-01-21 下午4.51.52.png
//出現(xiàn)錯(cuò)誤可以記得用斷點(diǎn)查詢,不要急,不要慌
#import "ViewController.h"
@interface ViewController ()
//第一個(gè)文本框
@property(nonatomic,weak)IBOutlet UITextField *num1TextField;
//第二個(gè)文本框
@property(nonatomic,weak)IBOutlet UITextField *num2TextField;
//文本標(biāo)簽
@property(nonatomic,weak)IBOutlet UILabel *resultLabel;
//計(jì)算
- (IBAction) coculate;
@end
@implementation ViewController
//IBAction 1.相當(dāng)于void 2.只有聲明返回值類型是IBAction才有資格和storyboard連線
//IBOutlet 他就是一個(gè)標(biāo)識符,標(biāo)志這個(gè)屬性可以與storyboard進(jìn)行連線
//計(jì)算
- (IBAction) coculate
{
NSString *num1Text = self.num1TextField.text;
NSString *num2Text = self.num2TextField.text;
//把字符串轉(zhuǎn)換為int類型
int result = num1Text.intValue + num2Text.intValue;
//改變文本標(biāo)簽的內(nèi)容
// NSLog(@"%@",num1Text);
self.resultLabel.text = [NSString stringWithFormat:@"%d",result];
//只要是自己或者自己的子控件叫出來的鍵盤,都可以通過這個(gè)方法來退出鍵盤
[self.view endEditing:YES];
}
@end
每天記住關(guān)于IOS的十個(gè)單詞 第三天
view //看法 風(fēng)景 看 視域(建筑學(xué))視圖
button //按鈕
textfield //文本框
label //標(biāo)簽
controller //控制器
property //財(cái)產(chǎn)
self //自己 同一的
progress //進(jìn)步 增長
center //中心 居中
frame //位置 尺寸