116,825 views / 2011.11.01 / 11:11 上午

mysql 1067错误一般出现在windows系统下,自定义data目录路径的时候。即使是最新的mysql5.5 安装包,在安装完成进行配置时,也会出现这个问题。


过程:安装msi文件,到最后一步配置时,可跳过,然后进入安装目录 /bin/下,找到MysqlInstanceConfig.exe,运行后,可按照提示一步一步配置。

Categories: 感悟 Tags:

Should’ve been invalidated iOS5开发错误2+

72,256 views / 2011.10.25 / 4:04 下午

iOS5推出后,赶紧升级手里的ios产品,发现有个错误始终无法解决,就是”Should’ve benn invalidated”,闪退. 排查了半天,最后发现是文件通过网络上传后,提前释放了连接导致的.把release行注释掉,程序正常了.


Categories: 感悟 Tags:

objective-c 遍历表格的方法0+

45,163 views / 2011.08.25 / 9:09 下午
for (int i = 0; i < [ptableView numberOfSections]; i++) {
    for (int j = 0; j < [ptableView numberOfRowsInSection:i]; j++) {
        NSUInteger ints[2] = {i,j};
        NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:ints length:2];
            UITableViewCell *cell = [ptableView cellForRowAtIndexPath:indexPath];
           //Here is your code


Categories: 感悟 Tags: ,

最近开发的乐助理360应用, 初次使用需要手机接受一条包含激活码的短信,  用户输入正确激活码后才能使用改应用. 所有的事情都做好了,杜工非常期待的提交给了苹果审核,结果人家给rejected了,原因是”我们收不到你们国家的短信,没法测试”,原文如下:

We began the review of your app but are not able to continue because we need demo phone number and verification code to fully access your app features. Please ensure that the demo account you provide includes any data necessary to demonstrate the functionality of your app features.

我了个去, 杜工怎么之前就没想到这点呢?于是一顿穷改, 加了一个固定的测试号码,只要输入这个号码,系统返回的激活码都是固定的就行了. 最后,重新提交审核,在review notes中客客气气的作下说明:

I’m sorry that our sms platform couldn’t send message to your country. So I added a special account as you mentioned in resolution center: 手机号码:130******* 激活码1234 So as long as you entered this phone No. exactly, the active code will always be 1234.
For that and some bug-fixed, I upload a new binary. Thank’s for your kindly help and best regards.

Categories: 感悟 Tags:


57,190 views / 2011.06.25 / 9:09 下午

If you have ever written an iPhone app that requires numeric input, then you surely know about the UIKeyboardTypeNumberPad. And if you have ever used that flavor of the iPhone’s keyboard, then you surely know that it lacks one very important feature: The UIKeyboardTypeNumberPad does not have a “return” key.

In fact every other keyboard type (except for the pretty similar UIKeyboardTypePhonePad) does offer the possibility to be dismissed by setting the returnKeyType property of the corresponding UITextInputTraits implementor. So how does one achieve the same effect with the number pad? We have found a workround!

When looking at the number pad, you’ll notice that there is an unused space on its bottom left. That’s where we are going to plug in our custom “return” key.

To make it short: take a screenshot, cut out the whole backspace key, flip it horizotally, clear its backspace symbol in Photoshop and overlay it with the text that we want on our “return” key. We’ve chosen to label it “DONE”. Now we have the image for our custom button’s UIControlStateNormal. Repeat the whole procedure (with a touched backspace key when taking the screenshot) to get a second image for our button’s UIControlStateHighlighted. Here’s the result:

Now back to coding. First we need to know when the number pad is going to be slided up on the screen so we can plug in our custom button before that happens. Luckily there’s a notification for exactly that purpose, and registering for it is as easy as:

[[NSNotificationCenter defaultCenter] addObserver:self 

Don’t forget to remove the observer from the notification center in the appropriate place once you’re done with the whole thing:

[[NSNotificationCenter defaultCenter] removeObserver:self];

Now we’re getting to the heart of it. All we have to do in the keyboardWillShow method is to locate the keyboard view and add our button to it. The keyboard view is part of a second UIWindow of our application as others have already figured out (see this thread). So we take a reference to that window (it will be the second window in most cases, so objectAtIndex:1 in the code below is fine), traverse its view hierarchy until we find the keyboard and add the button to its lower left:

- (void)keyboardWillShow:(NSNotification *)note {  
    // create custom button
    UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    doneButton.frame = CGRectMake(0, 163, 106, 53);
    doneButton.adjustsImageWhenHighlighted = NO;
    [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
    [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
    [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];

    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) {
        keyboard = [tempWindow.subviews objectAtIndex:i];
        // keyboard view found; add the custom button to it
        if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
            [keyboard addSubview:doneButton];

Voilà, that’s it! The empty space for our button starts at coordinate (0, 163) and has the dimensions (106, 53). The doneButton method has to be written now of course, but that’s not hard any more. Just make sure that you call resignFirstResponder on the text field that is being edited to have the keyboard slide down.

We’re “DONE”.


本文例子 downloaded as Xcode project
更新: download 3.0 compatible Xcode project.
最新的: download the newest version (可运行 2.0 – 4.0所有版本)



Categories: 分享 Tags: