一,修改狀態欄:
1.加入[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];但此方法只是不顯示狀態條,狀態條所占用的空間仍然存在。
2.可以修改Info.plist文件,在info.plist文件中加入一條新鍵值,命名為:UIStatusBarHidden;選擇Valuetype為Boolean,而後重新編譯運行。
3,修改屏幕顯示方向:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLa
4,得到項目的名字
//得到項目的名字,並設置在當前視圖標題上
self.title = [[[NSBundle mainBundle] infoDictionary] objectForKey:@CFBundleName];
5,設置當前視圖支持觸摸
setUserInteractionEnable
6.Button.userInteractionEnabled=NO,按鈕停止接受任何事件
7.Button.Enabled=NO,按鈕不顯示
8.獲得當前鼠標的位置
[NSEvent mouseLocation];
9.刷新UITableViewrController視圖
[self.TableView reloadData];
10.
字符串轉化為int
NSString的IntegerValue方法
11.整形轉化為字符串為StringWithFormat;
12.制作一個簡單的動畫:
- (IBAction)curlAction:(id)sender
{
//開始一個動畫
[UIView beginAnimations:nil context:NULL];
//設置動畫得時間間隔
[UIView setAnimationDuration:kTransitionDuration];
//設置動畫得旋轉方式
[UIView setAnimationTransition:([self.mainView superview] ?
UIViewAnimationTransitio
if ([self.flipToView superview])
{
[self.flipToView removeFromSuperview];
[self.containerView addSubview:self.mainView];
}
else
{
[self.mainView removeFromSuperview];
[self.containerView addSubview:self.flipToView];
}
[UIView commitAnimations];
}
13.使用隨機數
random((unsigned)(macn_absolute_time() &0xFFFFFFFF));
14。Quartz中是怎樣設置旋轉點得
UIImageView *imageview=[[UIImageview alloc] initWithImage:[UIImage imageNamed:@bg.png]];
imageView.layer.anchorPoint=CGPointMake(0.5,1.0);
15.隱藏NavigationBar
[self.navigationController setNavigationBarHidden:YES animated:YES];
16,根據CLLocation得到coordinate(坐標)而後打開google地圖:
NSString *mapUrl=[NSString stringWithFormat:@http://maps.google.com/maps?q=%f,%f,loc.latitude,loc.longitude];
NSURL *url=[NSURL URLWithString:mapUrl];
[[UIApplication sharedApplication] openURL:url];
17.日期格式化:
NSDataFormat *format=[NSDateFormat alloc]
[format setDateFormat:@hh:mm:ss];
NSDate *noew=[NSDate date];
NSString *str=[format stringFromDate:now];
18。webView使用:
webView loadRequest:[NSURLRequest alloc] initwithURL:[NSURL alloc]initWithStringt:@http://www.google.com];
18。通過通知調用方法:
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserve:self
selector:@selector(xxx:)
name:UIApplicationWillTermina
object:app];
19。遍歷所有視圖的方法:
其中cell是UITableViewCell,
for(UIView *oneView in cell.contentView.subviews)
{
if ([oneView isMemberOfClass:[UITextField class]])
{
textField = (UITextField *)oneView;
}
}
20.
1、背景音樂播放
這種播放音樂的方式導入框架#import ;
NSString *musicFilePath = [[NSBundle mainBundle] pathForResource:@changan ofType:@mp3];
//創建播放器
需要導入框架#import
NSString *thesoundFilePath = [[NSBundle mainBundle] pathForResource:@Clapping Crowd Studio 01 ofType:@caf];
CFURLRef thesoundURL = (CFURLRef) [NSURL fileURLWithPath:thesoundFilePath];
AudioServicesCreateSyste
//變量SoundID與URL對應
AudioServicesPlaySystemS
UILabel*label;
//設置換行
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
換行符還是n
比如NSString * xstring=@lineonenlinetwo