2015年(3)
分类: iOS平台
2015-08-13 11:21:16
将plist文件中的数据赋给数组
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"States" ofType:@"plist"];
NSArray *array = [NSArray arrayWithContentsOfFile:thePath];
//首先给不同的textField赋不同的且相邻的tag
//- (BOOL)textFieldShouldReturn:(UITextField *)textField
//{
// if ([textField returnKeyType] != UIReturnKeyDone)
// {
// NSInteger nextTag = [textField tag] + 1;
// UIView *nextTextField = [self.view viewWithTag:nextTag];
// [nextTextField becomeFirstResponder];
// }
// else {
// [textField resignFirstResponder];
// }
// return YES;
//}
点击键盘的Tap按钮,在不同的textField之间换行
有时候在 iPhone 游戏中,既要播放背景音乐,同时又要播放比如枪的开火音效。此时您可以试试以下方法
NSString *musicFilePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"wav"]; //创建音乐文件路径
NSURL *musicURL = [[NSURL alloc] initFileURLWithPath:musicFilePath];
AVAudioPlayer* musicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:musicURL error:nil];
[musicURL release];
[musicPlayer prepareToPlay];
//[musicPlayer setVolume:1]; //设置音量大小
//musicPlayer .numberOfLoops = -1;//设置音乐播放次数 -1为一直循环
要导入框架 AVFoundation.framework,头文件中 #import <AVFoundation/AVFoundation.h>;做成类的话则更方便。
隐藏状态栏[[UIApplication sharedApplication] setStatusBarHidden:YES];{
NSInteger nextTag = [textField tag] + 1;
UIView *nextTextField = [self.view viewWithTag:nextTag];
[nextTextField becomeFirstResponder];
}
else {
[textField resignFirstResponder];
}
}