我正在使用UITextField的方法becomeFirstResponder来显示键盘.这适用于iOS 7.但在iOS 8中,此方法不显示键盘.
UITextField *txtAddNew = [[UITextField alloc] initWithFrame:CGRectMake(10,10,240, 21)];
txtAddNew.font = [UIFont fontWithName:@"Helvetica" size:16];
txtAddNew.clearButtonMode = UITextFieldViewModeWhileEditing;
txtAddNew.returnKeyType = UIReturnKeyDone;
txtAddNew.delegate = self;
txtAddNew.autocorrectionType = UITextAutocorrectionTypeNo;
txtAddNew.tag = 15;
// Open keyboard
[txtAddNew becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)
在iOS 8中有什么办法吗?
以前我UILocalNotification在我的应用程序中用于提醒目的。
但如上所述 API 在 iOS 10.0 中已弃用,现在需要使用 UserNotifications Framework 的UNNotificationRequest.
使用UILocalNotification我可以设置触发日期以及重复间隔,如下所示:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSDate *tomorrow = [NSDate dateWithTimeInterval:(24*60*60) sinceDate:[NSDate date]];
localNotification.fireDate = tomorrow;
if(repeatUnit!=0){
localNotification.repeatInterval = NSWeekCalendarUnit;
}
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我可以设置明天通知触发的日期,并且我还设置了 1 周的重复间隔,该间隔将从触发日期开始。
如何使用 UserNotifications Framework 的UNNotificationRequest.
因为在新的API中我们可以使用triggerUNCalendarNotificationTrigger和UNTimeintervalNotificationTrigger来启动UNNotificationRequest。
有什么办法可以像这样设置两者UILocalNotification吗?