我需要在iPhone应用程序中显示文本,例如书籍的显示方式,例如:
我该怎么做呢?我找到了UITextView和UITextField以及UIScrollView对象,但我无法弄清楚如何正确使用它们......有什么建议吗?
我希望这是有道理的...
有没有人使用秒表基准测试,还是应该总是使用性能工具?有没有适合Java的免费工具?你用什么工具?
为了澄清我的担忧,由于操作系统调度,秒表基准测试会出错.在程序的给定运行中,操作系统可能会在您正在计时的函数中间安排另一个(或多个)进程.在Java中,如果你试图为一个线程化的应用程序计时,事情会更糟糕,因为JVM调度程序会在混合中引入更多的随机性.
基准测试时如何解决操作系统调度问题?
Archaelus在这篇文章中建议写一个新的格式例程来处理命名参数可能是一个很好的学习练习.因此,本着学习语言的精神,我编写了一个处理命名参数的格式化例程.
一个例子:
1> fout:format("hello ~s{name}, ~p{one}, ~p{two}, ~p{three}~n",[{one,1},{three,3},{name,"Mike"},{two,2}]).
hello Mike, 1, 2, 3
ok
Run Code Online (Sandbox Code Playgroud)
基准:
1> timer:tc(fout,benchmark_format_overhead,["hello ~s{name}, ~p{one}, ~p{two}, ~p{three}~n",[{one,1},{name,"Mike"},{three,3},{two,2}],100000]).
{421000,true}
= 4.21us per call
Run Code Online (Sandbox Code Playgroud)
虽然我怀疑这个开销大部分是由于循环,但是调用带有一个循环的函数会产生<1us的响应.
1> timer:tc(fout,benchmark_format_overhead,["hello ~s{name}, ~p{one}, ~p{two}, ~p{three}~n",[{one,1},{name,"Mike"},{three,3},{two,2}],1]).
{1,true}
Run Code Online (Sandbox Code Playgroud)
如果有更好的方法在erlang中进行基准测试,请告诉我.
守则:(
根据道格的建议修订)
-module(fout).
-export([format/2,benchmark_format_overhead/3]).
benchmark_format_overhead(_,_,0)->
true;
benchmark_format_overhead(OString,OList,Loops) ->
{FString,FNames}=parse_string(OString,ONames),
benchmark_format_overhead(OString,OList,Loops-1).
format(OString,ONames) ->
{FString,FNames}=parse_string(OString,ONames),
io:format(FString,FNames).
parse_string(FormatString,Names) ->
{F,N}=parse_format(FormatString),
{F,substitute_names(N,Names)}.
parse_format(FS) ->
parse_format(FS,"",[],"").
parse_format("",FormatString,ParamList,"")->
{lists:reverse(FormatString),lists:reverse(ParamList)};
parse_format([${|FS],FormatString,ParamList,"")->
parse_name(FS,FormatString,ParamList,"");
parse_format([$}|_FS],FormatString,_,_) ->
throw({'unmatched } found',lists:reverse(FormatString)});
parse_format([C|FS],FormatString,ParamList,"") ->
parse_format(FS,[C|FormatString],ParamList,"").
parse_name([$}|FS],FormatString,ParamList,ParamName) ->
parse_format(FS,FormatString,[list_to_atom(lists:reverse(ParamName))|ParamList],"");
parse_name([${|_FS],FormatString,_,_) ->
throw({'additional { found',lists:reverse(FormatString)});
parse_name([C|FS],FormatString,ParamList,ParamName) -> …Run Code Online (Sandbox Code Playgroud) 我今天开始考虑字体(字体)选择.我为工作做的一个网站带有这个专业的风格指南,详细的颜色选择,字体选择,间距等.这是我第一次看到这样的东西,但我不得不承认,他们所选择的确实看起来不错.
现在我已经读过关于色彩理论的知识,所以我知道补色和选择颜色方案,比如说1,2或3种颜色.所以我对我的宠物项目的那一面很好.
但我还没有真正看到Web上下文中的字体选择.我发现了一些关于打印字体的讨论,您可以选择下载并包含自定义字体.这不是网上的选择.您只能使用支持的浏览器(或操作系统).我有兴趣阅读有关IE和Firefox在Windows和Mac上支持的内容(对不起,Linux太过边缘,不能考虑除CSS字体系列后备之外的任何内容)以及这些字体传达的内容:它们是否严重,正式,休闲,邀请等
有人知道这样的事吗?
我有一个应用程序,我需要从UINavigationController的堆栈中删除一个视图,并将其替换为另一个.情况是第一个视图创建一个可编辑的项目,然后用该项目的编辑器替换它自己.当我在第一个视图中执行明显的解决方案时:
MyEditViewController *mevc = [[MYEditViewController alloc] initWithGizmo: gizmo];
[self retain];
[self.navigationController popViewControllerAnimated: NO];
[self.navigationController pushViewController: mevc animated: YES];
[self release];
Run Code Online (Sandbox Code Playgroud)
我的行为非常奇怪.通常编辑器视图会出现,但如果我尝试使用导航栏上的后退按钮,我会得到额外的屏幕,有些空白,有些只是搞砸了.标题也变得随机.就像导航堆栈完全被冲洗一样.
什么是解决这个问题的更好方法?
谢谢,马特
什么7n5lu是reddit URL
7n5lu
它是如何产生的?
更新:@Gerald,感谢您的代码.我最初认为这是对id的一些混淆.但是,它只是从整数转换为更紧凑的表示.我在想,为什么要这样做?为什么不使用原始整数本身!
>>> to36(4000)
'334'
>>> to36(4001)
'335'
Run Code Online (Sandbox Code Playgroud) 有没有人知道Win32在处理不区分大小写的文件名时使用的文化设置?
这是根据用户的文化而变化的,还是Win32使用文化不变的大小写规则?
我对头文件的使用有以下疑问.
1 - 在评论后加入警卫
/* Copyright Note and licence information (multiple lines) */
#ifndef FOO_H
#define FOO_H
// Header file contents
#endif
Run Code Online (Sandbox Code Playgroud)
Herb Sutter在他的"C++编码标准"一书中说,像上面这样的代码是有问题的.他说"#ifndef"语句应该出现在头文件的第一行.我觉得这并不令人信服.在头文件中你跟着你们/ gals吗?
2 - 在头文件中使用名称空间
#ifndef FOO_H
#define FOO_H
namespace FooNameSpace{
// Header file contents
}
#endif
Run Code Online (Sandbox Code Playgroud)
上面的代码是否使用了正确的做法?我的意思是,你在头文件中使用命名空间吗?我知道为什么在头文件中导入命名空间是没有意义的,但是如上所述的声明呢?
如果上面的方法是正确的,那么如何对另一个名称空间中的类进行" 转发声明 "呢?是不是
#ifndef FOO_H
#define FOO_H
namespace AnotherNameSpace{
class AnotherFoo; // forward declaration
}
namespace FooNameSpace{
// Use AnotherFoo here
}
#endif
Run Code Online (Sandbox Code Playgroud)
" 前向声明 "是避免" 循环依赖 " 的唯一方法,对吗?
我继承了一个包含一些巨大的switch语句块的项目,其中一些包含多达20个案例.什么是重写这些的好方法?
cocoa-touch ×2
iphone ×2
benchmarking ×1
c# ×1
c++ ×1
erlang ×1
fonts ×1
header-files ×1
java ×1
javascript ×1
python ×1
reddit ×1
refactoring ×1
ruby ×1
slug ×1
url ×1
winapi ×1