Archive for the 'Tips' Category

视力降低了吗,为什么看UILabel中的文字很模糊!

Feb 10 2010 Published by 黑眼圈 under Dev,Tips

喔喔,在使用UILabel等继承于UIView的控件时,如果frame的rect不是整数的情况下,就会显示起来看得很模糊.这通常出现在代码控制的界面中,控件是由计算的数值所决定的位置的时候。

解决方法就是把浮点数转换成整形。

No responses yet

使用arc4random获取随机数

Jun 22 2009 Published by 黑眼圈 under Tips

通常我们需要获得随机数的时候,假如直接使用了random()就会发现”为什么每次打开程序随机出来结果的顺序都一样?”,这是因为我们获得的随机数实际上都是伪随机数,所以在random之前需要使用srandom()函数获得一个seed来进行随机算法,并且通常是使用srandom(time(NULL)),把时间作为参数是为了获得的seed每次都不一样,当然理论上肯定是不一样的 XD

那么有没有更便捷的随机方法呢?

Continue Reading »

No responses yet

在Google Chart API里显示中文等非拉丁语系字符

Oct 19 2008 Published by 黑眼圈 under Tips

Google Chart API是google提供的一组实时表格绘制系统,只用提供参数进去,就能返回生成好的图片。
但是我在网上没有找不到使用中文或其他非拉丁语系语言(如日语,韩语)的方法,以至于大家都以为它不提供中文支持。因为直接使用中文做参数传进去,表格里会显示成乱码,p.s.后来调用出中文以后把url复制到chrome等地址栏是utf-8显示的浏览器,直接通过浏览器的地址栏往参数里写中文是可以的,因为始终是utf-8发送的编码。

在网站程序里用方法很简单:使用url encode把中文转换成16进制的编码就行了。

php直接调用urlencode()函数。

rails使用URI.encode()函数。

如果使用的是gchartrb,则把最后的to_url换成to_escaped_url就行了,不用自己调用encode。

c#使用Server.UrlEncode函数。

其他程序都一样各自调用API里的url encode就行了~

于是中文等不能直接显示的非拉丁语系文字转换以后就可以了,但是CJK中唯独中文有一个BUG。

Continue Reading »

No responses yet

SEO for Movable Type Blog

Sep 27 2008 Published by 黑眼圈 under Tips

How to create a template for keywords and meta description tag.

Movable Type missing keywords and description meta tag at the template.
SEO has not measure the standard too much, but I suggest you better do this than doing nothing.

“Better than not” that said the exact keywords in HEAD and that the description was not put to much more like that, so I’ll just follow the following points.

  • keywords: 5, 6 and each other the same page.
  • description: Approximately 100 characters or less.

btw,if you find out this article via the search engine, I guess you better do that :p

Continue Reading »

No responses yet