Sunday, April 12, 2009

在线程中更新界面

在线程中调用 -(void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait, 然后再在这个函数里面刷新界面的control。

在主线程里加入一个loading画面…

{
[window addSubview:view_loading];
[NSThread detachNewThreadSelector:@selector(init_backup:) toTarget:self withObject:nil];
}

- (void)init_backup:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// ...
int i = status;
[self performSelectorOnMainThread:@selector(show_loading:) withObject:[NSNumber numberWithInt:i] waitUntilDone:NO];

[view_loading removeFromSuperview];
[window addSubview:tabcontroller_main.view];
[pool release];
}

NSTimer检测不到按键的解决办法

在Timer的执行函数最后加上这段代码就可以了。

[[NSRunLoop currentRunLoop] runUntilDate: [NSDate distantPast]];

Saturday, March 21, 2009

iDeneb 10.5.6 on Lenovo E390

Step1: 查看E390硬件配置:
CPU Intel(R) Core(TM)2CPU T5500 @ 1.66GHZ 2CPUs
显卡:Intel(R) GMA950
声卡:RealTek HD Audio ALC883(声卡芯片可以用everestultimate查看)
内存:DDR2 667
无线网卡:3495abg, 此驱动至今无解,去村里买的usb无线网卡:华硕wl-167g

Step2: 硬盘拷贝
1.下载附件miniboot.,并解压
2.用硬盘安装助手把miniboot.iso写到你的目标分区-My Mac。要选中boot.ini
3.用硬盘安装助手把10.5.6的ISO写到你的安装分区 - Mac ISO。
4.用ddboot1h写入你的目标分区 - My Mac。
dd if=boot1h of=\\?\Device\YourHardDisk\YourPartition
for example:
dd if=C:\miboot\boot1h of=\\?\Device\Harddisk0\Partition2
=============================================================
注:用硬盘安装助手进行安装,至少需要两个主分区Primary Partition),一个大的(50G,label: My Mac)用来装系统,我们称之为目标分区;一个小的(10G,能放下ISO就行了, label: Mac ISO)用来写入ISO,我们称之为安装分区目标分区安装分区必须在同一个磁盘上。
参考链接:http://bbs.kenapple.com/thread-19898-1-1.html

Step3: 配置选项
这里是最重要的一步,配置选项选不好的话,很容易导致四国,菊花。至于怎么选,首先要看自己的硬件配置,其次就是要多尝试,失败了再重新选择配置,安装次数多了就找到窍门了。下面是我用的配置:注意,这里根本没有选择audio video驱动,
Customize:
Additional Fonts
X11
iDeneb Essential System

Patches 10.5.6 Ready
-Alternative Essential Patch
-PS2Fix for ACPI kext 10.5.6
Chipset
-ICHx Fixed

-Intel GMA950
-ALC883

Fix
- power management
-Idlehalt Fix
Applications
只选择了自己能用到的,该不装的就不装了。

上面的配置中的fix该不选的就不选,除非安装后遇到了问题。刚开始可以什么都不选,来装一遍,看能不能启动。出了问题,在boot时用-v选项查看问题所在。

重启机器,很幸运,看到了经典的多国语言的欢迎动画,这说明显卡驱动成功,并且QE/CI已经打开。如果能听到声音的话,那就完美了,一切搞定。

但是很有可能你会遇到下面的问题:

问题1:很不幸,重启后,显示蓝屏。
不过不要担心,这已经是幸运的,蓝屏意味着MAC OS系统的基本引导已经完成。是配置和加载显卡驱动的时候了。
重启,boot 参数 -s -v进入UNIX单用户模式。输入"mount -uw /"去掉整个磁盘的readonly权限。
cd /System/Library/Extentions/
rm -rf AppleIntelGMA950.kext
rm -rf AppleIntelGMA950GA.plugin
rm -rf AppleIntelGMA950GLDriver.bundle
rm -rf AppleIntelGMA950VADriver.bundle
rm -rf AppleIntelIntegratedFramebuffer.kext
exit

重启后,就进入注册页面了。创建帐号,看到久违的Mac桌面了。
选择苹果->about this mac菜单,可以看看能否成功识别cpu,mem。
费劲千辛万苦,我的双核cpu终于被正确识别:Processor: Intel@ CoreTM2 CPU T5500@1.66GHz
检查usb热插拔,鼠标,键盘,关机,等一切正常。

但是,到现在为止,屏幕的分辨率为1024×768,并不适合现在的E390宽屏。别着急,下面马上安装新的显卡驱动。

Step5: 安装无线网卡驱动,联网
安装华硕WL-167g驱动,一切OK。

Step6:安装显卡驱动
下载显卡驱动 GMA950.zip并安装
,重启,一切正常,现在的分辨率为1280×800,显示正常,字体也不发虚了。去about this mac查看,QE/CI是否已经开启,如果开启,则成功,否则还得费一番功夫重新去找驱动。

Step7:安装声卡驱动
下载显卡驱动ALC883audio.mpkg, 没有必要全部安装此软件包,只需要安装其中的两个。在package上点击鼠标右键->show package contents->Contents->Resources, 安装ALC883audio_6ports.pkg和ALCinject.pkg.
重启。System Preferences->Sound->Output,选择Internal Speakers 或者Head Phones. 找个声音文件试试新的驱动。

现在这个驱动,还是有点问题,就是在选择Internal Speakers时,耳机没有声音,或者选择耳机时,外放没有声音。必须手动的重新选择output才可以。还好这是个小问题,我很少用耳机在电脑上听东西。

至此,系统全部安装完成。10.5.6感觉不如10.5.5稳定,有的时候还时经常死机。
边使用,边学习,边解决吧。

Tuesday, March 17, 2009

mac 常用软件

编辑器: emacs,没办法已经离不开它了。

BBS:Welly

IM: Adium,小鸭子用来上MSN,QQ都可以,很方便。

浏览器:Firefox,已经习惯了,跨平台,强大的插件,良好的中文显示(Safari显示中文有的网页实在是很差,像sports.sina.com.cn)

office: googledocs, 只要有网络就可以了,像我这样在家里,单位经常编辑同一个文件,真的是很方便。

图像处理:Paintbrush,类似于Windows底下的画图,简单的操作都能满足。
Pixelmator,类似于photoshop,很好用。

网络电视:TVU能看美国的电视,很好,很强大。

Zip解压: Betterzip

chm阅读器: iChm

Monday, March 16, 2009

Navigation Bar

Navigation Bar处于屏幕的上方,在StatusBar的下面(如果StatusBar没有隐藏的话),占据44像素的高度。

Toolbar

toolbar位于屏幕的最低端,占据44像素的高度。

Thursday, March 12, 2009

Obj-C tutorial

One Obj-C tutorial for beginners:

http://cocoadevcentral.com/d/learn_objectivec/

尤其是对Memory Management的论述十分到位。

Tuesday, March 10, 2009

一个下载技术类电子书的网站

http://www.itpub.net

非常好,注册之后就可以下载,一口气下载了所有iPhone dev相关的书。

Monday, March 9, 2009

NSTimer

-(void)startTimer {
        frameTimer = [NSTimer scheduledTimerWithTimeInterval:TIMER_INTERVAL
                  target:self
                  selector:@selector(handleTimer:)
                  userInfo:nil
                  repeats:YES];
}
-(void)stopTimer {
        if (frameTimer != nil) {
                [frameTimer invalidate];
                frameTimer = nil; //note
        }
}

- (void)handleTimer: (NSTimer *) timer
{
        whichFrame ++;
        [self setNeedsDisplay];
}

Sunday, March 8, 2009

UIView

- [rootView addSubView:newView]

newView 将被添加到 [[rootView subViews] count]处。
举个例子,如果rootView已经有3个subview,当 addSubView操作后,rootView含有4个subview,最后一个subview为刚刚被添加的newView。最新被添加的view处于屏幕的最前面。

下面的代码将最后一个subview从subviews中删除:
[[[rootView subviews] objectAtIndex:[[rootView subViews] count]-1] removeFromSuperview];

- 给view加个标签
setTag可以给view加上标签,这样就可以很容易取回想要view:viewWithTag


Saturday, March 7, 2009

UIImage

UIImage   *bgImage = [UIImage imageNamed:@"ume_bg.png"]; // 320*480 PNG

CFDataRef bgImageData = CGDataProviderCopyData(CGImageGetDataProvider(bgImage.CGImage));


//int length = CFDataGetLength(bgImageData); //480*320*3

//size_t height = CGImageGetHeight(bgImage.CGImage); //480

//size_t width =  CGImageGetWidth(bgImage.CGImage);  //320

//size_t a1 = CGImageGetBitsPerComponent(bgImage.CGImage); //8

//size_t a2 = CGImageGetBitsPerPixel(bgImage.CGImage); //24 = 8 * 3(R G B)

//size_t a3 = CGImageGetBytesPerRow(bgImage.CGImage); //960 = 320 * 3(R G B)

const UInt8 *bgByte = CFDataGetBytePtr(bgImageData); // raw data


// get RGB data at position pos

int r = bgByte[pos];

int g = bgByte[pos+1];

int b = bgByte[pos+2];


/*

NSString *msg = [[NSString alloc] initWithFormat:@"pos(x:%d, y:%d) (%d, %d, %d)", xx, yy, r, g, b];

UIAlertView *alert = [[UIAlertView alloc]

initWithTitle:@"(x,y)"

message:msg

delegate:self

cancelButtonTitle:@"Phew!"

otherButtonTitles:nil];

[alert show];

[msg release];

[alert release];

*/

/*

UIImageView *umeView = [[UIImageView alloc] initWithFrame:CGRectMake(point.x, point.y-31, 42.0, 62.0)];

//load all the frames of ume animation

umeView.animationImages = [NSArray arrayWithObjects:

[UIImage imageNamed:@"ume_1.PNG"],

[UIImage imageNamed:@"ume_2.PNG"],

[UIImage imageNamed:@"ume_3.PNG"], nil];

umeView.animationDuration = 0.5;

umeView.animationRepeatCount = 0;

[umeView startAnimating];

[self.view addSubview:umeView];

[umeView stopAnimating];

[umeView release];

*/

写书的打算

又和出版社的朋友聊了一下,打算用三个月的时间出一本书。内容是iPhone SDK开发相关的东西。有写书的想法已经很久了,原来就是想纪录下自己平时做开发时的一些东西,一来可以记录每天的进度,二来可以给后来者以参考,让他们少走弯路。

3月7号,I have a plan.

Sunday, March 1, 2009

Status Bar

- status bar在屏幕的最顶端,占据20个像素的高度

- 怎样隐藏status bar:
方法一:在info.plist新增加一项,key=UIStatusBarHidden 鼠标右键“value Type"->"Boolean"然 后把value中的box选中。

方法二:[UIApplication sharedApplication]
setStatusBarHidden:YES animated:NO]

Sunday, February 22, 2009

lenovo E390 完美安装1eopard

受够了toolchian的不便,为了在iPhone上开发,考虑到maccbook7k多的价格,还是决定先在自己的lenovo E390笔记本上安装一下Leopard。我选择的版本为iDeneb v1.3 10.5.5. 利用硬盘安装助手。安装还是挺方便的。特别注意的几点:
1)分区最好为主分区
2)Chipset ICHx Fixed
3)kernel 9.4.0
4)键盘选中文,会安装中文输入法
5)intel 3495无线网卡无解,去村里买了 华硕WL-167G光盘自带驱动

下载iPhone2.2.1SDK会自动包含Xcode3.1

按照Beginning iPhone Development,Hello World成功。

mobile dev 开张

处女贴。庆祝。