- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在为 iOS 开发一个小的货币转换器,想从 UITextField
中读取一个 float 。不幸的是,我无法从 UITextField
中读取 float 。我在 Internet 上做了一些研究,但我尝试过的方法都没有奏效。我是 Objective-C 的新手,这是我自己的第一篇文章,所以请随时给我反馈和建议,以供以后发表。
这是 ViewController.m 中的代码:
//
// ViewController.m
// Currencyz
//
// Created by Daniel Putzer on 21/08/16.
// Copyright © 2016 Daniel Putzer. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize Dollar, Euro, DollarValue, EuroValue, Result, ReadIn;
- (void)viewDidLoad {
[super viewDidLoad];
[self setDollar: 0];
[self setResult: @""];
}
- (IBAction) ReadEuro:(id)sender
{
Euro = [EuroValue.text floatValue];
}
- (void) Calculate
{
Dollar = 1.13245 * Euro;
Result = [NSString stringWithFormat: @"%.2f", Dollar];
}
- (IBAction)CalculateDollar:(id)sender
{
[self Calculate];
[DollarValue setText: Result];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这是 ViewController.h:
//
// ViewController.h
// Currencyz
//
// Created by Daniel Putzer on 21/08/16.
// Copyright © 2016 Daniel Putzer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
float Euro;
float Dollar;
NSString *Result;
NSString *ReadIn;
IBOutlet UILabel *DollarValue;
IBOutlet UITextField *EuroValue;
}
@property float Euro;
@property float Dollar;
@property NSString *Result;
@property NSString *ReadIn;
@property IBOutlet UILabel *DollarValue;
@property IBOutlet UITextField *EuroValue;
@end
我不明白为什么它不将变量 Euro
设置为在 UITextField
中输入的金额。
最佳答案
- (void)viewDidLoad {
[super viewDidLoad];
[self setDollar: 0];
[self setResult: @""];
[self ReadEuro];
}
- (void) ReadEuro
{
Euro = [EuroValue.text floatValue];
NSLog("Euro value is : %0.02f", Euro);
}
试试这个,看看是否打印出你的值。
关于ios - 从 UITextfield 读入 float,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39063052/
假设您有 2 个文件,如下所示。 file_1_october.csv file_2_november.csv 文件具有相同的列。所以我想在 R 中读取这两个文件,我可以使用 map 轻松完成。我还想
我有一个制表符分隔的文本文件: 0730000 John 1 01 225 000 000 当我将它读入 R 时 stud_stats data.table::f
似乎最直观的是 .rdata 文件可能是 R 加载的快速文件格式,但是在扫描一些堆栈帖子时,似乎更多的注意力集中在提高 .csv 或其他格式的加载时间上。有确定的答案吗? 最佳答案 不是一个明确的答案
我是 R 的新手,目前在读取 .csv 文件并将其转换为 data.frame 时遇到了很多麻烦7 列。这是我正在做的: gene_symbols_table head(gene_symbols_t
基本上我有一个格式如下所示的 csv: csv 有 11 列,前五列和后五列完全相同。我希望能够读取 csv 并将第一列和第五列(期间和支出)的所有实例存储在一个列表中,它们具有值,并对另一个列表中的
我对 Julia 比较陌生,正在寻找一种有效的方法来从文本文件中读取并将每个“列”存储在数组中(我有 2 列,但通用解决方案也很棒)。例如,我想要输入 1 2 3 4 5 6
基本上我有一个格式如下所示的 csv: csv 有 11 列,前五列和后五列完全相同。我希望能够读取 csv 并将第一列和第五列(期间和支出)的所有实例存储在一个列表中,它们具有值,并对另一个列表中的
我的程序分配了一个 32 位 int,随后尝试使用 read(2) 从套接字将 4 个字节读入 int 有时读取不完整并返回读取 2 个字节。有什么方法可以从中恢复吗?我想我必须在 int 的中途生成
我有大量的 CSV 文件。有些标题从第一行开始,其他标题从第 3 行开始,其他的从第 7 行开始,依此类推。 标题看起来都一样,它们只是从不同文件的不同行开始。有没有办法有条件地 read.csv 文
我写了一个小程序来从 csv 文件中读取数据: using System; using System.Collections.Generic; using System.Linq; using Sys
我需要读入一个包含 10,000 个整数的列表,并将它们按升序放置在一个 vector 中。请注意,我不是在然后阅读排序,而是在同时阅读时排序。 我这样做是为了学习。我意识到阅读时排序是 O(n^2)
我有一个问题。不幸的是,我没有找到任何答案。如何将参数传递给脚本,这是另一个命令的结果。例如: ls | ./myscript.sh 我想将 ls 的结果传递给 myscript。如果我执行上面的命
我在读取扩展 ASCII 字符并将其转换为十进制值时遇到问题。我试过这样做: unsigned char temp; while(temp = cin.get != EOF) { cout << (i
我已经通过以下命令加载了文本文件。我想从 contents 中删除由 \n 分隔的第一行标题行。怎么做? txtfile = open(filepath, "rt") contents = txtfi
希望一切顺利...我正在将数据集输入到 sklearn 算法中进行分类,但找不到任何简单的数据集来开始,所以我自己制作了数据集。但有一个问题... import numpy as np import
我有一个 .csv 文件,它有 3 行和 5 列,值为 0、1、2、3、50 或 100。我将它从 Excel 工作表保存到 .csv 文件。我正在尝试使用 C++ 读取 .csv 文件,并根据最后三
我有一个 HTML 文件,它将作为我要发送的电子邮件的模板。 html 中有一些字段是可变的。我想知道是否有一种可靠的方法可以用变量替换 HTML 文件中的占位符。我知道我可以 string.Repl
我从未使用过 JSON 文件,但我有实现 JSON 文件的任务,我需要将其转换为 IEnumerable。当我尝试对 JSON 对象进行反序列化时,我得到一个异常,上面写着: An unhandled
我正在尝试阅读 IFormFile从这样的 HTTP POST 请求中收到: public async Task UploadDocument([FromForm]DataWrapper data)
我有一个包含大量多行文本 block 的文件。我想将该文件读入一个字符向量列表——每个 block 一个。我对 scan()、read.table() 等函数的文档的阅读似乎表明一行的结尾将结束向量。
我是一名优秀的程序员,十分优秀!