我正在寻找一种方法来处理Ruby/Rails中的整数ordinalization,即."st","nd","rd"和"th"后缀为整数.Ruby on Rails用于使用"ordinalize"方法扩展FixNum,但该功能似乎已在版本3中弃用.
我目前只是使用旧Rails方法的源代码,这很好......但这似乎是大多数脚本语言/ Web框架内置的功能,我觉得Rails背后的人必须有一个理由弃用功能(也许它现在可以在Ruby中使用了吗?).
请指教!
Flask-WTF's documentation states that:
Flask-WTF provides you a FileField to handle file uploading, it will automatically draw data from flask.request.files if the form is posted. The data attribute of FileField will be an instance of Werkzeug FileStorage.
但是,当我使用时FileField,data发布后的属性不是FileStorage对象.相反,它是None(如果我enctype="multipart/form-data"按照文档中的建议定义我的表单)或文件名作为字符串(如果我没有定义enctype).
这是相关的Jinja2模板:
{% from "_form.html" import render_field %}
{% block body %}
<section class="page-width-container" id="offset-content">
<div id="utility-box">
<h1 class="utility-header">Settings</h1>
{{ message }}
<form action="/settings" method="post" enctype="multipart/form-data">
{{ render_field(form.photo) }}
<input type="submit" …Run Code Online (Sandbox Code Playgroud) 我正在使用该方法[string sizeWithFont:constrainedToSize:lineBreakMode:]来估计textView我正在调整大小的高度.但是,它似乎始终返回不正确的大小.为了调试,我编写了以下代码:
self.textView.font = [UIFont systemFontOfSize:14.0]; // It was this before, anyways
NSLog(@"Real width: %lf %lf", self.textView.contentSize.width, self.textView.frame.size.width);
NSLog(@"Real height: %lf", self.textView.contentSize.height);
NSLog(@"Estimated width: %lf", kOTMessageCellTextWidth);
NSLog(@"Estimated height: %lf", ([message.message sizeWithFont:[UIFont systemFontOfSize:14.0]
constrainedToSize:CGSizeMake(kOTMessageCellTextWidth, CGFLOAT_MAX)
lineBreakMode:UILineBreakModeWordWrap].height));
Run Code Online (Sandbox Code Playgroud)
但是,上面的代码显示我得到了不一致的结果:
实际宽度:223.000000 223.000000
实际高度:52.000000
预计宽度:223.000000
预计高度:36.000000
实际宽度:223.000000 223.000000
实际高度:142.000000
估计宽度:223.000000
估计高度:126.000000
实际宽度:223.000000 223.000000
实际高度:142.000000
估计宽度:223.000000
估计高度: 126.000000
我在这个类似的问题中注意到(显然)textView有一些填充限制了它的实际宽度.那里的建议是减少了传递给sizeWithFont:某个数字的宽度.建议的数字是11.
我的问题:有没有办法以编程方式实际检索这个值,或者是否有一些我错过了指定这个数字的文档?似乎这个数字应该是可用的,不应该被猜测和检查,但我找不到可靠的方法来识别它.
提前致谢.
cocoa-touch ×1
date ×1
flask ×1
iphone ×1
objective-c ×1
python ×1
python-2.7 ×1
ruby ×1
uitextview ×1
wtforms ×1