Day.01.21 UI簡(jiǎn)單的加法計(jì)算器小文件

屏幕快照 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)識(shí)符,標(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];
    
    //只要是自己或者自己的子控件叫出來(lái)的鍵盤,都可以通過(guò)這個(gè)方法來(lái)退出鍵盤
    [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)步 增長(zhǎng)
center //中心  居中
frame //位置  尺寸
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容