以下问题和解决方法供大家参考:
某些界面不显示,定制键盘不正常。界面问题,原来是有些界面控件的行为改变了;1)比如说:UISegmentedControl,[segmentControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];原来segmentControl.selectedSegmentIndex = 0;这样的调用会导致直接调用一次segmentAction。但是在ios5中没有调用。要手动去执行一下,可以这样改,在设置完selectedSegmentIndex以后,加上if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { [self segmentAction:segmentControl];}2)非pad界面的数字键盘,自定义增加一个ok按钮,在ios4上可以正确执行的,ios5上也不行了比如说这个:http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key经改进如下可以执行在ios5上正常显示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 itif(([[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES)||[[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){ CGRect frame = CGRectMake(0.0f, 162.0f, 106.0f, 53.0f);if ((orientation == UIInterfaceOrientationLandscapeLeft) || (orientation == UIInterfaceOrientationLandscapeRight)){ frame = CGRectMake(0.0f, 116.0f, 162.0f, 53.0f);}[doneBt setFrame:frame];[keyboard addSubview:doneBt];break;}}3)uiviewcontroller的- (void)viewWillAppear:(BOOL)animated方法,显示或者隐藏的时候都被调用。而- (void)viewWillDisappear:(BOOL)animated从不被调用了4)UINavigationBar的背景自定义图片要实现navigationBar的背景自定义图片,是直接定义一个UINavigationBar的category,并重写drawRect方法,在ios5下面,navigationBar的drawRect方法似乎都不被调用了。解决方法是:在app delegate里面的application didFinishLaunchingWithOptions方法中,加入[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"xxx.png"] forBarMetrics:UIBarMetricsDefault];5)ios5的键盘尺寸ios5的键盘尺寸不再固定为以前的216,而是有216和252两种。比如说英文键盘的尺寸是216,而中文拼音键盘的尺寸是252,切换输入法之类的操作都可能会引起键盘尺寸的变化,所以随时要注意键盘上面多出的那一块会不会把用户界面给挡掉,更具体的情形,可以看我在这里的回复http://www.cocoachina.com/bbs/read.php?tid=77630&page=2#4576406)自定义的UIView在使用UIScrollView的时候,ios4下,拖动滚动的时候,会不断调用layoutSubviews这个方法。但是在ios5里面经常不调用,需要自己增加如下一个方法- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { [self setNeedsLayout];}}