Archives

自定义UIBarButtonItem的问题

显示一个按钮

1
2
3
4
5
6
7
8
9
10
11
12
13
14
UIButton *editButton = [UIButton buttonWithType:UIButtonTypeCustom];

editButton.frame=CGRectMake(0, 0, 50, 30);

[editButton setBackgroundImage:[UIImage imageNamed:@"edit_off.png"] forState:UIControlStateNormal];

[editButton setBackgroundImage:[UIImage imageNamed:@"edit_on.png"] forState:UIControlStateHighlighted];

[editButton addTarget:self action:@selector(doneAction)  forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithCustomView:editButton];

self.navigationItem.rightBarButtonItem = editItem;

在iOS5 没有editButton.frame=CGRectMake(0, 0, 50, 30) 按钮会显示不出来。在iOS4 下 是不必须的…

ARC有效的工程中导人非ARC的代码

使用新特性ARC创建的工程,如果导入未进行ARC优化的代码,会产生编辑错误,比较粗暴的办法就是手动删除MRC代码,但是工作量巨大。

我最近做个一个项目,因为导入了新浪微博SDK,使用了一个比较方便的办法,就是让这些SDK在编译的时候不使用ARC。

设置方法如下:

Amazon的核心价值观

从小团队一步步走过来,一开始人少,日常工作就可以默默统一。但企业到一定规模,就开始需要明确这样的有些务虚的东西。

企业的核心价值观,是那些大家认同的、应当共同坚持和维护的原则。在形成明确的价值观后,一个团队会对不符合的行为形成自发的修正。

Amazon的领导力原则

Amazon Leadership Principles

无论你是一线的员工,还是一个大型团队的经理,你都是Amazon的领导者。以下是我们每位Amazon人都努力遵循的原则:

Whether you are an individual contributor or a manager of a large team, you are an Amazon leader. These are our leadership principles and every Amazonian is guided by these principles.

客户第一
领导者总是以客户为出发点,积极而有活力地工作,以赢得和保持客户的信任。虽然领导者们也很关注竞争对手,但他们对客户更痴迷。

Customer Obsession
Leaders start with the customer and work backwards. They work vigorously to earn and keep customer trust. Although leaders pay attention to competitors, they obsess over customers.

主人翁意识
领导者都是公司的拥有者。他们着眼长远,不为眼前而牺牲公司的长期利益。他们总能站在比自己团队更高的角度,代表整个公司做出决策和行动,并且从不会说“这事儿不归我管”。

Ownership
Leaders are owners. They think long term and don’t sacrifice long-term value for short-term results. They act on behalf of the entire company, beyond just their own team. They never say “that’s not my job”.

创新并保持简单
领导者都应要求自己的团队,持续在创新上思考和实现,并保持简单有效。他们有足够的眼界,能从任何地方发现新点子,并且不会因为”这不是我们自己想出来的“而弃之不用。当我们打算做一件别人都没做过的事时,我们已经做好了长期可能被人误解的准备。

Invent and Simplify
Leaders expect and require innovation and invention from their teams and always find ways to simplify. They are externally aware, look for new ideas from everywhere, and are not limited by “not invented here”. As we do new things, we accept that we may be misunderstood for long periods of time.

坚持正确的做事
领导者能够坚持正确的做事。他们应当有很好的商业判断和直觉。

Are Right, A Lot
Leaders are right a lot. They have strong business judgment and good instincts.

招聘并培养最优秀的人
每次招聘或提拔下属,领导者都应该对他们的绩效有更高的要求。他们能发现,并为团队招募到最出类拔萃的人才。同时,要发掘潜在的领导者人才,并非常专注的培养他们。

Hire and Develop the Best
Leaders raise the performance bar with every hire and promotion. They recognize exceptional talent, and willingly move them throughout the organization. Leaders develop leaders and take seriously their role in coaching others.

坚持高标准
领导者要有近乎严苛的高标准,即使在很多人看来这个标准已经有些变态的高了。同时,也要持续的提高标准的门槛,使得团队能够在产品、服务和流程上有高质量的产出。领导者能及时弥补遇到的缺陷和问题,不会让它们出现在产出中。

Insist on the Highest Standards
Leaders have relentlessly high standards – many people may think these standards are unreasonably high. Leaders are continually raising the bar and drive their teams to deliver high quality products, services and processes. Leaders ensure that defects do not get sent down the line and that problems are fixed so they stay fixed.

富有全局观
局限自己的思维,就像一个人只会说一些自我应验的预言一样。领导者应大胆地描绘愿景,并确保传达到位,以激励团队给出更好的结果。同时,也要独立思考,并想方设法服务于客户。

Think Big
Thinking small is a self-fulfilling prophecy. Leaders create and communicate a bold direction that inspires results. They think differently and look around corners for ways to serve customers.

积极行动
速度决定一切。很多判断和行动,即使后来发现做错了,也都是可以回溯撤销的,并且事前并不需要大量的调研。同时,我们也鼓励承担有预期的风险(不鼓励盲目的尝试)。

Bias for Action
Speed matters in business. Many decisions and actions are reversible and do not need extensive study. We value calculated risk taking.

节俭
如果一个事不能给客户带来好处,这个钱我们尽量不花。节俭让我们富余出更多的资源,自给自足,并能激发我们产生更丰富的想法,发挥更好的创意。在招聘名额、预算和固定开支方面,我们控制的非常谨慎。

Frugality
We try not to spend money on things that don’t matter to customers. Frugality breeds resourcefulness, self-sufficiency and invention. There are no extra points for headcount, budget size or fixed expense.

直言不讳地自我批评
领导者不应因为自己或团队看起来不错就止步不前。即使有时显得尴尬,他们工作时心中也总是带着问题。在评估自己和团队时,寻找自己离最好还有多远。

Vocally Self Critical
Leaders do not believe their or their team’s body odor smells of perfume. Leaders come forward with problems or information, even when doing so is awkward or embarrassing. Leaders benchmark themselves and their teams against the best.

赢得他人的信任
领导者应发自内心的保持开放、虚心的倾听,并总是愿意找出并改进自己目前最大的不足之处。

Earn Trust of Others
Leaders are sincerely open-minded, genuinely listen, and are willing to examine their strongest convictions with humility.

深入细节
领导者应可以在各个层级工作,保持对细节的关注并时常检查。没有什么事是他完全不清楚的。

Dive Deep
Leaders operate at all levels, stay connected to the details and audit frequently. No task is beneath them.

可依赖,保持怀疑并承担责任
领导者遇到自己不赞成的方案,即使有些面子上不舒服或者有时很耗费精力,依然有义务做出挑战。他们对待错误应当保持坚定和公平,不因面子而妥协。一旦做出决策,他们愿意承担全部责任。

Have Backbone; Disagree and Commit
Leaders are obligated to respectfully challenge decisions when they disagree, even when doing so is uncomfortable or exhausting. Leaders have conviction and are tenacious. They do not compromise for the sake of social cohesion. Once a decision is determined, they commit wholly.

交付结果
领导者关注所负责事情的关键输入,并按时保证质量的交付结果。即使有挫折,他们也能应对自如并且永不自满。

Deliver Results
Leaders focus on the key inputs for their business and deliver them with the right quality and in a timely fashion. Despite setbacks, they rise to the occasion and never settle.

http://micy.cn/blog/post/161

SSD的写入放大 - Write amplification

写入放大(WA)是闪存和固态硬盘之间相关联的一个属性,因为闪存必须先删除才能改写(我们也叫“编程“),在执行这些操作的时候,移动(或重写)用户数据和元数据(metadata)不止一次。这些多次的操作,不但增加了写入数据量,减少了SSD的使用寿命,而且还吃光了闪存的带宽(间接地影响了随机写入性能)。许多因素会影响到SSD的写入放大,下面我就来稍微详细的解释一下。

早在2008年,Intel公司和SiliconSystems公司(2009 年被西部数字收购)第一次提出了写入放大并在公开稿件里用到这个术语。他们当时的说法是,写入算法不可能低于1,但是这种说法在2009年被SandForce打破,SandForce说他们的写入放大是0.5。

基本SSD操作方式:

Spring--quartz中cronExpression配置说明

字段 允许值 允许的特殊字符
秒 0-59 , - /
分 0-59 , -
/
小时 0-23 , - /
日期 1-31 , -
? / L W C
月份 1-12 或者 JAN-DEC , - /
星期 1-7 或者 SUN-SAT , -
? / L C #
年(可选) 留空, 1970-2099 , - * /

The ‘‘ character is used to specify all values. For example, ““ in the minute field means “every minute”.
”字符被用来指定所有的值。如:”“在分钟的字段域里表示“每分钟”。
The ‘?’ character is allowed for the day-of-month and day-of-week fields. It is used to specify ‘no specific value’. This is useful when you need to specify something in one of the two fileds, but not the other. See the examples below for clarification.
“?”字符只在日期域和星期域中使用。它被用来指定“非明确的值”。当你需要通过在这两个域中的一个来指定一些东西的时候,它是有用的。看下面的例子你就会明白。
月份中的日期和星期中的日期这两个元素时互斥的一起应该通过设置一个问号(?)来表明不想设置那个字段

The ‘-‘ character is used to specify ranges For example “10-12” in the hour field means “the hours 10, 11 and 12”.
“-”字符被用来指定一个范围。如:“10-12”在小时域意味着“10点、11点、12点”。

The ‘,’ character is used to specify additional values. For example “MON,WED,FRI” in the day-of-week field means “the days Monday, Wednesday, and Friday”.
“,”字符被用来指定另外的值。如:“MON,WED,FRI”在星期域里表示”星期一、星期三、星期五”.

The ‘/‘ character is used to specify increments. For example “0/15” in the seconds field means “the seconds 0, 15, 30, and 45”. And “5/15” in the seconds field means “the seconds 5, 20, 35, and 50”. Specifying ‘*’ before the ‘/‘ is equivalent to specifying 0 is the value to start with. Essentially, for each field in the expression, there is a set of numbers that can be turned on or off. For seconds and minutes, the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to 31, and for months 1 to 12. The “/“ character simply helps you turn on every “nth” value in the given set. Thus “7/6” in the month field only turns on month “7”, it does NOT mean every 6th month, please note that subtlety.

The ‘L’ character is allowed for the day-of-month and day-of-week fields. This character is short-hand for “last”, but it has different meaning in each of the two fields. For example, the value “L” in the day-of-month field means “the last day of the month” - day 31 for January, day 28 for February on non-leap years. If used in the day-of-week field by itself, it simply means “7” or “SAT”. But if used in the day-of-week field after another value, it means “the last xxx day of the month” - for example “6L” means “the last friday of the month”. When using the ‘L’ option, it is important not to specify lists, or ranges of values, as you’ll get confusing results.

L是‘last’的省略写法可以表示day-of-month和day-of-week域,但在两个字段中的意思不同,例如day-of-month域中表示一个月的最后一天,
如果在day-of-week域表示‘7’或者‘SAT’,如果在day-of-week域中前面加上数字,它表示一个月的最后几天,例如‘6L’就表示一个月的最后一个
星期五,

The ‘W’ character is allowed for the day-of-month field. This character is used to specify the weekday (Monday-Friday) nearest the given day. As an example, if you were to specify “15W” as the value for the day-of-month field, the meaning is: “the nearest weekday to the 15th of the month”. So if the 15th is a Saturday, the trigger will fire on Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th. However if you specify “1W” as the value for day-of-month, and the 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not ‘jump’ over the boundary of a month’s days. The ‘W’ character can only be specified when the day-of-month is a single day, not a range or list of days
.
The ‘L’ and ‘W’ characters can also be combined for the day-of-month expression to yield ‘LW’, which translates to “last weekday of the month”.

The ‘#’ character is allowed for the day-of-week field. This character is used to specify “the nth” XXX day of the month. For example, the value of “6#3” in the day-of-week field means the third Friday of the month (day 6 = Friday and “#3” = the 3rd one in the month). Other examples: “2#1” = the first Monday of the month and “4#5” = the fifth Wednesday of the month. Note that if you specify “#5” and there is not 5 of the given day-of-week in the month, then no firing will occur that month.

The ‘C’ character is allowed for the day-of-month and day-of-week fields. This character is short-hand for “calendar”. This means values are calculated against the associated calendar, if any. If no calendar is associated, then it is equivalent to having an all-inclusive calendar. A value of “5C” in the day-of-month field means “the first day included by the calendar on or after the 5th”. A value of “1C” in the day-of-week field means “the first day included by the calendar on or after sunday”.
关于cronExpression的介绍:

字段 允许值 允许的特殊字符
秒 0-59 , - /
分 0-59 , -
/
小时 0-23 , - /
日期 1-31 , -
? / L W C
月份 1-12 或者 JAN-DEC , - /
星期 1-7 或者 SUN-SAT , -
? / L C #
年(可选) 留空, 1970-2099 , - /
表达式意义
“0 0 12
?” 每天中午12点触发
“0 15 10 ?
“ 每天上午10:15触发
“0 15 10
?” 每天上午10:15触发
“0 15 10
? “ 每天上午10:15触发
“0 15 10 ? 2005” 2005年的每天上午10:15触发
“0 14 ?” 在每天下午2点到下午2:59期间的每1分钟触发
“0 0/5 14
?” 在每天下午2点到下午2:55期间的每5分钟触发
“0 0/5 14,18
?” 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发
“0 0-5 14
?” 在每天下午2点到下午2:05期间的每1分钟触发
“0 10,44 14 ? 3 WED” 每年三月的星期三的下午2:10和2:44触发
“0 15 10 ?
MON-FRI” 周一至周五的上午10:15触发
“0 15 10 15 ?” 每月15日上午10:15触发
“0 15 10 L
?” 每月最后一日的上午10:15触发
“0 15 10 ? 6L” 每月的最后一个星期五上午10:15触发
“0 15 10 ?
6L 2002-2005” 2002年至2005年的每月的最后一个星期五上午10:15触发
“0 15 10 ? 6#3” 每月的第三个星期五上午10:15触发
每天早上6点
0 6

每两个小时
0 /2
晚上11点到早上8点之间每两个小时,早上八点
0 23-7/2,8
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4
1-3
1月1日早上4点
0 4 1 1 *

quartz的高级特性不仅如此
1 数据库存储
2 集群支持
3 数据库持久化任务,trigger
4 trigger 的停止,运行
5 任务的任意添加
6 比corntrigger 更详尽的任务安排
7 线程的内部数据交换

引起Iphone应用被App Store拒绝的原因

Vibration. It is not permitted to use continuous vibration in your apps - short bursts as warnings is all that is allowed. Don’t bother trying to set up a timer to keep the vibration going, it will cause your app to be rejected.

Linking to private frameworks. This is obvious, but somehow in playing around with stuff we had linked to the MoviePlayer.framework. That’s a no-no, and cost us about ten days while we unlinked that framework, recompiled, and then resubmitted.

Improper handling of editing in tableview cells. Also obvious, but be aware that if you enable table cell editing, you’ll have to manually specify which cells should respond to editing controls and which should not. We had some random prefs cells in one of our early apps that were able to be swiped to bring up a ‘delete’ badge. Of course it didn’t do anything, but Apple justly considered this poor design and rejected our app.

Icons. Make sure the 57 pixel icon is identical to the 512 pixel version. Also, use a different icon if you are creating ‘lite’ and ‘pro’ versions of your app (i.e., free and paid). Using the same icon for both sends your app straight to … you guessed it … the bin.

Copying existing functionality. This one is much more subtle and insidious, and has probably affected the great percentage of developers. In addition to the widely publicized Podcaster debacle, reports from user comments indicate that Apple is casting a wide net when looking for duplicated functionality. Mini web browsers, or apps that essentially show web pages, seem particularly vulnerable, even if they add new and/or useful functionality. Stay away from email clients as well.

Using appropriate keyboard type. If your app asks for a phone number or other numeral-only input and you present a keyboard that also includes the possibility of entering standard alpha-numeric input … yep. (Thanks Jeremy1026)

Version numbers. If your app is currently at version 0.99 or below, you’d better consider giving it a promotion as Apple seems to prefer 1.0 and above. One of ours was recently rejected for being .016, with a message suggesting that our version number wasn’t even numeric. When we resubmitted the same app from scratch as version 1.0, it went through.

Network Reachability. If your app requires any type of network access you need to make sure it works when that access isn’t available. If it doesn’t it will be rejected. Apple provides sample code to test this which you can use as-is in most cases:http://developer.apple.com/library/ios/samplecode/Reachability/index.html

//=========================================================

振动。它是不允许的,在你的应用程序中使用连续振动 - 短时间作为警告是所有被允许的。不要理会试图建立一个计时器,以保持振动,它会导致您的应用程序被拒绝。

链接到私人框架。这是显而易见的,但不知何故在玩玩泥巴,我们已链接到MoviePlayer.framework。这是一个没有没有,和成本我们十天左右,而我们无关联的框架,重新编译,然后重新提交。

编辑处理不当tableview细胞。也是显而易见的,但要注意,如果启用表格单元格编辑,你必须手动指定哪些细胞应该响应编辑控件不应。我们已经在我们早期的应用程序,能够刷卡带来了一个“删除”徽章之一一些随机Prefs的细胞。当然,它没有做任何事情,但苹果公正地考虑这个可怜的设计,并拒绝了我们的的应用程序。

图标。确保57像素的图标是相同的512像素版本。此外,使用不同的图标,如果你正在创建“LITE”和“亲”你的应用程序的版本(即,免费和付费)。使用两个相同的图标,直接发送您的应用程序… …你猜对了… …完事。

复制现有的功能。这一个是更加微妙和阴险,并有可能影响开发商的很大比例。除了广泛宣传播客崩溃,从用户的意见的报告表明,苹果是铸造一个大网时复制功能。小型的Web浏览器,或应用程序,基本上显示网页,显得尤为脆弱,即使他们添加的新的和/或有用的功能。从电子邮件客户端以及。

使用适当的键盘类型。如果您的应用程序要求一个电话号码或其他数字,只有输入和你目前的键盘还包括进入标准的字母数字输入… YEP的可能性。 (谢谢Jeremy1026)

版本号。如果您的应用程序目前的版本为0.99或以下,你最好考虑给它一个推广苹果似乎更喜欢1.0及以上。我们最近拒绝为0.016,这表明我们的版本号,甚至没有数字的消息。当我们重新提交相同的应用程序1.0版从头的,它通过了。

网络可达性。如果您的应用程序需要任何类型的网络访问,您需要确保它的工作原理,访问不可用时。如果它不将被拒绝。苹果公司提供的示例代码来测试,您可以使用在大多数情况下是:
http://developer.apple.com/library/ios/samplecode/Reachability/index.html

www.J2meGame.com精心收集。

Objective-C内存管理教程和原理剖析

前言
初学objectice-C的朋友都有一个困惑,总觉得对objective-C的内存管理机制琢磨不透,程序经常内存泄漏或莫名其妙的崩溃。我在这里总结了自己对objective-C内存管理机制的研究成果和经验,写了这么一个由浅入深的教程。希望对大家有所帮助,也欢迎大家一起探讨。

此文涉及的内存管理是针对于继承于NSObject的Class。

获取iphone目录下所有图片

NSArray pngs = [[NSBundle mainBundle] pathsForResourcesOfType:@”png” inDirectory:nil];
for (id png in pngs)
{
NSString
name = [png lastPathComponent];
if([name rangeOfString:@”page_”].location!=NSNotFound)
{
UIImage *image = [UIImage imageNamed:[png lastPathComponent]];
}
}

QRals:简单又实用的二维码制作工具

QRals是一是一款极其简单的二维码制作工具,你几乎第一眼就能看懂怎么操作了,整个网站就就只有一个页面,网站中没有其它页面可以点击,期间你执行任何操作也不会跳转到其他的页面,所有的操作所有的功能都在第一个页面中即可完成。

阳历转换成阴历的源代码

-(NSString )LunarForSolar:(NSDate )solarDate

{

//天干名称

NSArray *cTianGan = [NSArrayarrayWithObjects:@”甲”,@”乙”,@”丙”,@”丁”,@”戊”,@”己”,@”庚”,@”辛”,@”壬”,@”癸”, nil];

//地支名称

NSArray *cDiZhi = [NSArrayarrayWithObjects:@”子”,@”丑”,@”寅”,@”卯”,@”辰”,@”巳”,@”午”,@”未”,@”申”,@”酉”,@”戌”,@”亥”,nil];

//属相名称

NSArray *cShuXiang = [NSArrayarrayWithObjects:@”鼠”,@”牛”,@”虎”,@”兔”,@”龙”,@”蛇”,@”马”,@”羊”,@”猴”,@”鸡”,@”狗”,@”猪”,nil];