IOS 11 widget does not expand when the "Show more" button is clicked

The problem is that the widget does not expand when you click the "Show more" button. Based on multiple users, the problem has been interrupted since the iOS11 update. It will work on the same device, then for some reason it will not work. In addition, we can create and run the application on the device when it will work, and at other times it will not work, which makes it difficult to confirm whether the problem is fixed.

This is the code skeleton that is used:

#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

These warnings are printed on the console:

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

This widget works great with iOS 10.

+4
source share

Source: https://habr.com/ru/post/1686374/


All Articles