My TodayViewController
class is implemented as follows:
#import "TodayViewController.h"
#import <NotificationCenter/NotificationCenter.h>
@interface TodayViewController () <NCWidgetProviding>
@end
@implementation TodayViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSLog(@"yeehaw");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
// Perform any setup necessary in order to update the view.
// If an error is encountered, use NCUpdateResultFailed
// If there's no update required, use NCUpdateResultNoData
// If there's an update, use NCUpdateResultNewData
NSLog(@"gitalong");
completionHandler(NCUpdateResultNewData);
}
- (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets{
NSLog(@"yowza!");
return UIEdgeInsetsZero;
}
@end
Basically this is the boilerplate implementation that XCode provides when you create a Today
target in your app. The only changes I've made are to add some NSLog()
calls in each of the functions, and to remove the default left margin in the widgetMarginInsetsForProposedMarginInsets()
function (as per the method in this SO thread).
However, when I look at the system log output, none of my NSLog
statements are being output, and the default left margin has not gone away, so I'm thinking that for some reason, my app is not reading/processing the TodayViewController
class at all, even though it is otherwise displaying my MainInterface
storyboard correctly.
Does anyone know why this might be happening?
UPDATE
A detail I forgot to mention is that the MainInterface.storyboard
file I was using to implement the interface was copied into this project from another version of the same project. I was able to fix this problem by recreating the entire project from scratch and recreating the interface from scratch as well, so the MainInterface.storyboard
file I used in the "working" project was the original one generated by XCode. While this strategy fixed my immediate problem, I still don't understand why the storyboard
file that I imported from another project didn't work. This poses a problem for interface reuse. I'd still like to know how to link an imported storyboard
file to a custom ViewController
.