我在这种模式下创建了一个本地通知:
AppDelegate.m在午餐时间
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
// Setup each action thar will appear in the notification
UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
acceptAction.identifier = @"ACCEPT_ACTION"; // Identifier is returned in handleActionWithIdentifier: after the user taps on an action
acceptAction.title = @"ACCEPT_TITLE";
acceptAction.activationMode = UIUserNotificationActivationModeForeground; //Brings the app into the foreground when action tapped
UIMutableUserNotificationCategory *not_cat = [[UIMutableUserNotificationCategory alloc] init];
not_cat.identifier = @"testCategory";
[not_cat setActions:@[acceptAction] forContext:UIUserNotificationActionContextDefault];
NSSet *categories = [NSSet setWithObjects:not_cat, nil];
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound …Run Code Online (Sandbox Code Playgroud) 我想读一篇很长的文字:
NSString *text =@"Long test with dot. I want speaching pause when read dot. How can I do?";
AVSpeechSynthesizer *synthesizer = [AVSpeechSynthesizer new];
[synthesizer setDelegate:self];
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:[self.defaults objectForKey:LANGUAGE]];
utterance.rate = 0.28;
[synthesizer speakUtterance:utterance];
Run Code Online (Sandbox Code Playgroud)
我想合成器检测点并暂停100毫秒.
可能吗?我能怎么做 ??
我想通过按下按钮将状态栏的颜色从白色更改为黑色,PROGRAMMATICALLY仅在单个ViewController中
这是代码:
- (UIStatusBarStyle)preferredStatusBarStyle {
NSLog(@"PreferredStatusBarStyle");
if(nav_bar.alpha==1)
{
NSLog(@"->UIStatusBarStyleBlackOpaque");
return UIStatusBarStyleBlackOpaque;
}
else
{
NSLog(@"->UIStatusBarStyleLightContent");
return UIStatusBarStyleLightContent;
}}
Run Code Online (Sandbox Code Playgroud)
然后,当我按下按钮动作是:
[self setNeedsStatusBarAppearanceUpdate];
Run Code Online (Sandbox Code Playgroud)
但这不起作用!
当我按下按钮日志时,根据navbar.alpha写入正确的状态,但状态栏文本颜色保持UIStatusBarStyleBlackOpaque,就像出现视图时一样.