Created
May 7, 2024 13:41
-
-
Save pookjw/fea5764cb9c98e56cc7a90725dda41cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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