小编Tej*_*mbe的帖子

becomeFirstResponder在iOS 8中不起作用

我正在使用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中有什么办法吗?

iphone ios ios7 ios8 ios8.1

19
推荐指数
2
解决办法
2万
查看次数

如何在 UNNotificationRequest 中设置重复间隔和触发日期

以前我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中我们可以使用triggerUNCalendarNotificationTriggerUNTimeintervalNotificationTrigger来启动UNNotificationRequest

有什么办法可以像这样设置两者UILocalNotification吗?

iphone xcode objective-c ios uilocalnotification

5
推荐指数
1
解决办法
3208
查看次数

标签 统计

ios ×2

iphone ×2

ios7 ×1

ios8 ×1

ios8.1 ×1

objective-c ×1

uilocalnotification ×1

xcode ×1