//
// main.m
//
//
// Created by unknown on 12/6/1.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
// 好用的列按鈕項目建立巨集
#define BARBUTTON(TITLE, SELECTOR) [[UIBarButtonItem alloc] \
initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self \
action:SELECTOR]
//Step 5.a 設計一個ViewController
@interface convertController:UIViewController
{
UITextField *field1;
UITextField *field2;
}
-(IBAction)doConvert:(id)sender;
@end
@implementation convertController
//Step 5.b 複寫loadView來佈置此ViewController的layerOut
-(void)loadView
{
CGRect appFrame=[[UIScreen mainScreen]applicationFrame];//
self.view=[[UIView alloc]initWithFrame:appFrame];
field1 = [[UITextField alloc] initWithFrame:
CGRectMake(185.0, 16.0, 97.0, 31.0)];
field1.borderStyle = UITextBorderStyleRoundedRect;
field1.keyboardType = UIKeyboardTypeDecimalPad;
field1.clearButtonMode = UITextFieldViewModeAlways;
field2 = [[UITextField alloc] initWithFrame:
CGRectMake(185.0, 72.0, 97.0, 31.0)];
field2.borderStyle = UITextBorderStyleRoundedRect;
field2.enabled = NO;
UILabel *label1 = [[UILabel alloc] initWithFrame:
CGRectMake(95.0, 19.0, 82.0, 21.0)];
label1.text = @"Fahrenheit";
label1.textAlignment = UITextAlignmentLeft;
label1.backgroundColor = [UIColor clearColor];
UILabel *label2 = [[UILabel alloc] initWithFrame:
CGRectMake(121.0, 77.0, 56.0, 21.0)];
label2.text = @"Celsius";
label2.textAlignment = UITextAlignmentLeft;
label2.backgroundColor = [UIColor clearColor];
// 將各元件加入內容視圖裡
[self.view addSubview:field1];
[self.view addSubview:field2];
[self.view addSubview:label1];
[self.view addSubview:label2];
// 設定標題文字,加入Convert按鈕
self.title = @"Converter";
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Convert", @selector(doConvert:));
}
-(IBAction)doConvert:(id)sender
{
float invalue = [[field1 text] floatValue];
float outvalue = (invalue - 32.0f) * 5.0f / 9.0f;
[field2 setText:[NSString stringWithFormat:@"%3.2f", outvalue]];
[field1 resignFirstResponder];
}
@end
//=====================
//Step 1.建立UIApplicationDelegaye class
@interface converDelegate :NSObject<UIApplicationDelegate>
{
//Step 2.加入window 指標
UIWindow *_window;
}
@end
@implementation converDelegate
//Step 3.複寫applicationDidFinishLaunching
-(void)applicationDidFinishLaunching:(UIApplication *)application
{
//Step 4.構建window,並且保留在_window
_window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
//Step 5.建構一個UINavigationController,並且初始化一個converController 物件當做RootViewController
UINavigationController *nc=[[UINavigationController alloc]initWithRootViewController:[[convertController alloc]init]];
//Step 6.把nc挂入到window的Root
[_window setRootViewController:nc];
//Step 7.show window
[_window makeKeyAndVisible];
}
@end
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"converDelegate");
}
}
分享到:
相关推荐
NULL 博文链接:https://luckfox.iteye.com/blog/1546732
如果有自己的服务器,如果想查看当前IIS连接情况:例如有多少个请求,每个请求的动作,请求的Url,请求的IP等信息,使用... 不过要特别注意,在第一次使用IIS Request Viewer功能时,极有可能会弹出来一个错误窗口
Steelray Project Viewer
HTMLViewer HTMLViewer HTMLViewer HTMLViewer HTMLViewer
即使还未安装 Visio,使用 Visio Viewer 也可打开、查看或打印 Visio 绘图。不过,使用 Visio Viewer 不能编辑、保存或创建新的 Visio 绘图。要进行这些操作,需要安装 Visio 完整版。如果你使用 Visio 完整版创建和...
Adobe SVGViewer 插件 要想用浏览器查看SVG矢量图,必须要装一个控件,可能有多种控件,但是我一直用这个Adobe的SVG Viewer,只可以adobe在收购Micromedia之后就不在更新这个插件了
Viewer.js 是一款强大的图片查看器,像门户网站一般都会有各自的图片查看器,如果您正需要一款强大的图片查看器,也许 Viewer.js 是一个很好的选择。Viewer.js 有以下特点: 支持移动设备触摸事件 支持响应式 支持...
The HtmlViewer component set consists of the THtmlViewer TFrameViewerand TFrameBrowser components
model-viewer:一个Web组件用于在Web和AR中轻松显示交互式3D模型!
一个系统进程的查看和“KILL”工具,尽管类似的工具也有不少,但这个软件还是非常有自己的特色。非常轻松地更改进程的优先级;非常轻松地将一个进程注册或取消注册为“服务”;非常有特色的脚本功能;大多数时候,你...
FlyCapture 2 Viewer FlyCap2Viewer 2.12.3.2 x64 FLIR Camera tools FLIR公司的网络摄像机直接配置软件和直接在线预览软件,不是SDK,适合只是为了快速配置相机的应用。 FlyCap2 Viewer Release (x64) 是在由...
vnc viewer中文版是一款简单的远程控制软件。vnc viewer中文版可通过在需要连接的计算机上安装vnc服务,通过服务器帐号和密码进行连接,软件支持不同的系统连接,是一款跨平台连接工具。 vnc viewer中文版使用...
realsense-viewer配置参数
viewer的js压缩文件
iExif Viewer
cad viewer8.0正版,请放心使用
chrome office viewer插件
联影医疗自研DICOM查看工具(U_VIEWER),方便快捷! 大家有使用上的反馈请发送到以下邮箱:u_viewer@united-imaging.com. 谢谢