Skip to content

Commit

Permalink
fixed robertwijas#56 app extension support added by defining preproce…
Browse files Browse the repository at this point in the history
…ssor macro ‘UISS_APP_EXTENSION’
  • Loading branch information
Konstantinos Tsichlis committed Jul 4, 2017
1 parent 20260c9 commit a238085
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Project/UISS/UISS.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ - (void)loadStyleSynchronously {

- (void)refreshViews {
[[NSNotificationCenter defaultCenter] postNotificationName:UISSWillRefreshViewsNotification object:self];

#if !defined(UISS_APP_EXTENSION)
//This code is not available for app extensions (see today extension)
for (UIWindow *window in [UIApplication sharedApplication].windows) {
for (UIView *view in window.subviews) {
[view removeFromSuperview];
[window addSubview:view];
}
}

#endif
[[NSNotificationCenter defaultCenter] postNotificationName:UISSDidRefreshViewsNotification object:self];
}

Expand Down Expand Up @@ -286,6 +287,8 @@ - (void)statusWindowControllerDidSelect:(UISSStatusViewController *)statusWindow
}

- (void)presentConsoleViewController {
#if !defined(UISS_APP_EXTENSION)
//This code is not available for app extensions (see today extension)
UISSConsoleViewController *consoleViewController = [[UISSConsoleViewController alloc] initWithUISS:self];
consoleViewController.modalPresentationStyle = UIModalPresentationFormSheet;

Expand All @@ -302,6 +305,7 @@ - (void)presentConsoleViewController {
} else {
[presentingViewController presentViewController:consoleViewController animated:YES completion:nil];
}
#endif
}

@end
5 changes: 4 additions & 1 deletion Project/UISS/UISSSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
UISSSettingDescriptor *settingDescriptor = self.settingDescriptors[(NSUInteger) indexPath.section];

if (settingDescriptor.editorType == UISSSettingDescriptorEditorTypeText) {
#if !defined(UISS_APP_EXTENSION)
//This code is not available for app extensions (see today extension)
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Change Setting"
message:settingDescriptor.title
delegate:self
Expand All @@ -160,6 +162,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
textField.keyboardType = settingDescriptor.keyboardType;

[alertView show];
#endif
}
}

Expand All @@ -183,4 +186,4 @@ - (void)switchAccessoryViewValueChanged:(UISwitch *)switchAccessoryView {
settingDescriptor.valueChangeHandler(@(switchAccessoryView.on));
}

@end
@end
12 changes: 11 additions & 1 deletion Project/UISS/UISSStatusWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ - (void)dealloc

- (id)init
{
#if !defined(UISS_APP_EXTENSION)
//This code is not available for app extensions (see today extension)
self = [super initWithFrame:[UIApplication sharedApplication].statusBarFrame];
#else
self = [super initWithFrame:CGRectZero];
#endif
self.clipsToBounds = YES;
self.backgroundColor = [UIColor clearColor];
if (self) {
Expand All @@ -37,9 +42,14 @@ - (void)didChangeStatusBarFrame:(NSNotification *)notification;
});
}

- (void)updateLayout;
- (void)updateLayout
{
#if !defined(UISS_APP_EXTENSION)
//This code is not available for app extensions (see today extension)
self.frame = [self frameForOrientation:[UIApplication sharedApplication].statusBarOrientation];
#else
self.frame = [self frameForOrientation:UIInterfaceOrientationUnknown];
#endif
self.rootViewController.view.frame = self.bounds;
}

Expand Down

0 comments on commit a238085

Please sign in to comment.