读书人

UINavigationBar,UIBarButtonItem 相干

发布时间: 2012-06-26 10:04:14 作者: rapoo

UINavigationBar,UIBarButtonItem 相关
1. Adding a Custom UIBarButtonItem
We will use an image in the resources folder called “back.png”. To insert the image as the back button, add this piece of code to the AppDelegate.m file. This should be in the application:didFinishLaunchingWihOptions method.

if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];}


If you see, here we are asking if navbar will respondToSelector to avoid crash on iOS4!



读书人网 >移动开发

热点推荐