点击“显示更多”按钮时,iOS 11 Widget不会展开

时间:2017-09-26 03:13:44

标签: ios widget ios11 notificationcenter

问题是当点按“显示更多”按钮时,小部件不会展开。 基于多个用户,问题是iOS11更新后间歇性的问题。在相同的设备上它会工作,然后由于某种原因它将无法工作。此外,我们可以一次在设备上构建和运行应用程序,并且在另一时间它不起作用,这使得难以确认问题是否已修复。

这是使用的代码框架:

#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>

@interface TodayViewController () <NCWidgetProviding,myCustomDelegate>

@end

@implementation TodayViewController

- (void)viewDidLoad {
[super viewDidLoad];
// if objects are not drawn, draw them (uilable, uiviews ...etc)
  [self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeExpanded];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {

completionHandler(NCUpdateResultNewData);
}
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize{

if (activeDisplayMode == NCWidgetDisplayModeCompact) {
    self.preferredContentSize = maxSize;

 }else{   
    CGFloat per = 0.7;
    CGSize s = CGSizeMake(maxSize.width,maxSize.height*per);
    self.preferredContentSize = s;
  }
}
@end

这些警告会打印到控制台:

2017-09-25 23:00:41.705036-0400 myapp[6758:3887858] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x1c0119860> (Domain: group.com.mycompany. myapp, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
2017-09-25 23:00:41.776214-0400 myapp[6758:3887858] [MC] Loaded MobileCoreServices.framework
2017-09-25 23:00:42.057996-0400 myapp[6758:3887858] [Common] _BSMachError: port 6c03; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2017-09-25 23:01:51.544741-0400 myapp[6758:3887858] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction

此小部件与iOS 10完美配合。

0 个答案:

没有答案