iOS6、7、8、9新特性总汇和适配说明 (11)

- (id)initWithBase64Encoding:(NSString *)base64String;

- (NSString *)base64Encoding;

 

[Format Time: 0.0008 seconds]

 

十六、使用UIApplicationUserDidTakeScreenshotNotification来检查截图

在iOS7之前,像Snapshot或是Facebook Poke这样的app是使用一些很精巧的方法来检测用户是否有截图。然而,iOS7提供一个崭新的推送方法:UIApplicationUserDidTakeScreenshotNotification。只要像往常一样订阅即可知道什么时候截图了。

注意:UIApplicationUserDidTakeScreenshotNotification 将会在截图完成之后显示。现在在截图截取之前无法得到通知。希望苹果会在iOS8当中增加UIApplicationUserWillTakeScreenshotNotification。

十七、实现多语言语音合成

如果可以让app说话会不会很好呢?iOS7加入了两个新类:AVSpeechSynthesizer 以及AVSpeechUtterance。这两个类可以给你的app发声。很有意思不是吗?有多种语言可供选择——Siri不会说的语言也有,比如说巴西葡萄牙语。

使用这两个类给app提供语言合成的功能非常简单。AVSpeechUtterance 代表你想说什么,如何说。AVSpeechSynthesizer 用来发出这些声音,见以下代码片段:

Crayon Syntax Highlighter v2.7.1

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];

AVSpeechUtterance *utterance =

[AVSpeechUtterance speechUtteranceWithString:@"Wow, I have such a nice voice!"];

utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;

utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // defaults to your system language

[synthesizer speakUtterance:utterance];

1

2

3

4

5

6

 

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];

AVSpeechUtterance *utterance =

[AVSpeechUtterance speechUtteranceWithString:@"Wow, I have such a nice voice!"];

utterance.rate = AVSpeechUtteranceMaximumSpeechRate / 4.0f;

utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]; // defaults to your system language

[synthesizer speakUtterance:utterance];

 

[Format Time: 0.0020 seconds]

 

十八、使用了新的UIScreenEdgePanGestureRecognizer

UIScreenEdgePanGestureRecognizer 继承自UIPanGestureRecognizer ,它可以让你从屏幕边界即可检测手势。

使用新的手势识别器很简单,见以下:

Crayon Syntax Highlighter v2.7.1

UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleScreenEdgeRecognizer:)];

recognizer.edges = UIRectEdgeLeft;

[self.view addGestureRecognizer:recognizer];

1

2

3

 

UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleScreenEdgeRecognizer:)];

recognizer.edges = UIRectEdgeLeft;

[self.view addGestureRecognizer:recognizer];

 

[Format Time: 0.0013 seconds]

 

十九、使用UIScrollViewKeyboardDismissMode实现了Message app的行为

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwgywp.html