Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pookjw/303ca03ddc87c46bebb77cf3e123a310 to your computer and use it in GitHub Desktop.
Save pookjw/303ca03ddc87c46bebb77cf3e123a310 to your computer and use it in GitHub Desktop.
WindowResizability on UIKit
#import "SceneDelegate.hpp"
#import "RootViewController.hpp"
#import <objc/message.h>
@implementation SceneDelegate
- (void)dealloc {
[_window release];
[super dealloc];
}
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
UIWindowScene *windowScene = static_cast<UIWindowScene *>(scene);
// MRUISceneSizeRestrictions
id sizeRestrictions = reinterpret_cast<id (*)(id, SEL)>(objc_msgSend)(windowScene, NSSelectorFromString(@"sizeRestrictions"));
reinterpret_cast<void (*)(id, SEL, CGRect)>(objc_msgSend)(sizeRestrictions, NSSelectorFromString(@"setMinimumSize:"), CGRectMake(100.f, 100.f, 0.f, 392.f));
reinterpret_cast<void (*)(id, SEL, CGRect)>(objc_msgSend)(sizeRestrictions, NSSelectorFromString(@"setMaximumSize:"), CGRectMake(400.f, 400.f, 0.f, 392.f));
UIWindow *window = [[UIWindow alloc] initWithWindowScene:windowScene];
RootViewController *rootViewController = [RootViewController new];
window.rootViewController = rootViewController;
[rootViewController release];
[window makeKeyAndVisible];
self.window = window;
[window release];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment