ios10

Can't create a range in Swift 3

点点圈 提交于 2019-12-18 02:19:10
问题 I am trying to make a range in Swift 3 that I already had in Swift 2 but it keeps giving me this error: String may not be indexed with 'Int', it has variable size elements Here is my code: let range = expireRange!.startIndex.advancedBy(n: 7) ..< expireRange!.startIndex.advancedBy(n: 16) expiredRange is a Range<Index>? In Swift 2, I had: let range = expireRange!.startIndex.advancedBy(7)...expireRange!.startIndex.advancedBy(16) 回答1: In Swift 3, "Collections move their index", see A New Model

WKWebView not rendering correctly in iOS 10

◇◆丶佛笑我妖孽 提交于 2019-12-18 02:02:12
问题 I have WKWebView inside the UITableViewCell. The web view load request and then after finished loading, I'll resize the web view height to be equal to its content height, then adjust table view cell height to fit accordingly. What happened was the web view only displays the area that fit the screen size. When I scroll down, everything is white. But I see that the web view rendered with correct height, tap and hold on the white area on the web view still see selection. Zooming with pinch makes

WKWebView not rendering correctly in iOS 10

二次信任 提交于 2019-12-18 02:02:06
问题 I have WKWebView inside the UITableViewCell. The web view load request and then after finished loading, I'll resize the web view height to be equal to its content height, then adjust table view cell height to fit accordingly. What happened was the web view only displays the area that fit the screen size. When I scroll down, everything is white. But I see that the web view rendered with correct height, tap and hold on the white area on the web view still see selection. Zooming with pinch makes

Accessing Core Data from both container app and extension

泪湿孤枕 提交于 2019-12-18 01:15:42
问题 I'm developing app and share extension and trying to use core data. But when I'm inserting items in the extension those items only visible in extension but not from container app (e.g I perform NSFetchRequest from app and getting zero items but in app I got >0). I'm using the following code for getting the persistent container: lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "appname") container.loadPersistentStores(completionHandler: {

UserNotification in 3 days then repeat every day/hour - iOS 10

拟墨画扇 提交于 2019-12-17 20:35:31
问题 UILocalNotification has been depreciated so I would like to update my code to the UserNotification framework: let alertDays = 3.0 let alertSeconds = alertDays * 24.0 * 60.0 * 60.0 let localNotification:UILocalNotification = UILocalNotification() localNotification.alertAction = "Reminder" localNotification.alertTitle = "Reminder Title" localNotification.alertBody = "Reminder Message" localNotification.fireDate = Foundation.Date(timeIntervalSinceNow: alertSeconds) localNotification

Multiple UNUserNotifications not firing

老子叫甜甜 提交于 2019-12-17 16:51:00
问题 I'm setting multiple UNUsernotifications as below, - (void)viewDidLoad { [super viewDidLoad]; notifCount = 0; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (!error) { NSLog(@"request succeeded!"); [self set10Notif]; } }]; } In the set10Notif method, I'm setting

Multiple UNUserNotifications not firing

好久不见. 提交于 2019-12-17 16:50:03
问题 I'm setting multiple UNUsernotifications as below, - (void)viewDidLoad { [super viewDidLoad]; notifCount = 0; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (!error) { NSLog(@"request succeeded!"); [self set10Notif]; } }]; } In the set10Notif method, I'm setting

Determine user's “Temperature Unit” setting on iOS 10 (Celsius / Fahrenheit)

孤者浪人 提交于 2019-12-17 16:28:22
问题 iOS 10 adds the ability for the user to set their "Temperature Unit" choice under Settings > General > Language & Region > Temperature Unit. How can my app programmatically determine this setting so it can display the right temperature unit? I poured through NSLocale.h and didn't see anything relevant. (Before iOS 10, it was sufficient to test if the locale used metric and assume that metric users want to use Celsius. This is no longer the case.) 回答1: There is this article by Alexandre

AVPlayer playback fails while AVAssetExportSession is active as of iOS 10

亡梦爱人 提交于 2019-12-17 15:42:38
问题 AVPlayer will randomly just play audio, not showing the video track... Playing video correctly with AVPlayer while having an active compression session of AVAssetExportSession:exportAsynchronouslyWithCompletionHandler is now failing. It seems it causes some instability that persists until the app goes into the background and comes back. Examining AVURLAsset when video playback fails, there is a video track even though there is no video output. I also don't get any errors from the compressor

Swift 3 ObjC Optional Protocol Method Not Called in Subclass

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 15:38:29
问题 I have the following class hierarchy: class ScrollableViewController: UIViewController, UITableViewDelegate { // ... } That implements one UITableViewDelegate protocol method, e.g. tableView:willDisplayCellAt: In my class SpecificScrollableViewController , which inherits from ScrollableViewController , new optional protocol methods don't get called any more, e.g. tableView(_:heightForRowAt:) 回答1: tl;dr you need to prefix the function declaration with its Objective-C declaration, e.g. @objc