Skip to content

Instantly share code, notes, and snippets.

@pookjw
Created May 7, 2024 13:41
Show Gist options
  • Save pookjw/fea5764cb9c98e56cc7a90725dda41cc to your computer and use it in GitHub Desktop.
Save pookjw/fea5764cb9c98e56cc7a90725dda41cc to your computer and use it in GitHub Desktop.
#import "ViewController.h"
#import <objc/message.h>
#import <dlfcn.h>
OBJC_EXPORT id objc_msgSendSuper2(void);
extern BOOL UIImagePickerLoadPhotoLibraryIfNecessary(void);
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = UIColor.systemBackgroundColor;
NSURL *demoURL = [NSBundle.mainBundle URLForResource:@"demo" withExtension:@"mp4"];
__block typeof(self) unretainedSelf = self;
UIButton *videoEditorControllerButton = [UIButton systemButtonWithPrimaryAction:[UIAction actionWithTitle:@"UIVideoEditorController" image:nil identifier:nil handler:^(__kindof UIAction * _Nonnull action) {
// Loads PhotoLibrary Framework
UIImagePickerLoadPhotoLibraryIfNecessary();
UIVideoEditorController *videoEditorViewController = [UIVideoEditorController alloc];
struct objc_super superInfo = { videoEditorViewController, [videoEditorViewController class] };
videoEditorViewController = ((id (*)(struct objc_super *, SEL))objc_msgSendSuper2)(&superInfo, @selector(init));
videoEditorViewController.videoPath = [demoURL path];
[unretainedSelf presentViewController:videoEditorViewController animated:YES completion:nil];
[videoEditorViewController release];
}]];
videoEditorControllerButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:videoEditorControllerButton];
[NSLayoutConstraint activateConstraints:@[
[videoEditorControllerButton.topAnchor constraintEqualToAnchor:self.view.topAnchor],
[videoEditorControllerButton.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[videoEditorControllerButton.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[videoEditorControllerButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
]];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment