首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

iPhone开发札记(五)

2012-06-28 
iPhone开发笔记(五)NSLog([[UIDevice currentDevice] localizedModel])// iPhone on both devices35、不

iPhone开发笔记(五)
NSLog([[UIDevice currentDevice] localizedModel]);
// "iPhone" on both devices

35、不让iphone进入休眠模式:
[UIApplication sharedApplication].idleTimerDisabled=YES;

36、一定时间后触发事件:
[self performSelector:@selector(getIT) withObject:self afterDelay:2.0f];//2秒后执行getIT函数

37、更改navication bar背景
在m文件顶端加入如下代码:
@interface UINavigationBar (MyCustomNavBar)
@end
@implementation UINavigationBar (MyCustomNavBar)
- (void) drawRect:(CGRect)rect {
? ? UIImage *barImage = [UIImage imageNamed:@"bar.png"];
? ? [barImage drawInRect:rect];
}
@end

38、更改tab bar背景
在m文件顶端加入如下代码:
@implementation UITabBar (CustomImage)
- (void)drawRect:(CGRect)rect {
? ? UIImage *image = [UIImage imageNamed: @"bar.png"];
? ? [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

39、切换tab bar时触发的事件
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
? ? NSLog(@"%i",viewController.tabBarItem.tag);
}

40、更改UISearch Bar的按钮文字
for(id cc in [searchtext subviews]){
? ? if([cc isKindOfClass:[UIButton class]]){
? ? ? ? [btn setTitle:@"Search"? forState:UIControlStateNormal];
? ? }
}

热点排行