I'm following this tutorial of building React native app using Apple's PencilKit: https://blog.logrocket.com/build-react-native-drawing-app-pencilkit/
The project I'm trying to run: https://github.com/hrupesh/RNPencilKit.git
but on the last step of adding ToolPicker, I was baffled to find out the ToolPicker only shows when I send the app to the background and resume it. I'm not familiar with React native so any help will be much appreciated!
Here is the code that called the ToolPicker:
const App: React.FC = () => {
const drawingRef = useRef(null);
useEffect(() => {
setTimeout(() => {
UIManager.dispatchViewManagerCommand(
findNodeHandle(drawingRef?.current),
UIManager.getViewManagerConfig('PencilKit').Commands.setupToolPicker,
undefined,
);
}, 400);
}, []);
-(void) setupToolPicker(
dispatch_async(dispatch_get_main_queue(), ^{
self->_toolPicker = [[PKToolPicker alloc] init];
[self->_toolPicker setVisible:true forFirstResponder:self->_canvasView];
[self->_toolPicker addObserver:self->_canvasView];
[self->_toolPicker addObserver:self]:
[self->_canvasView becomeFirstResponder];
self->_undoManager = [[self->_canvasView undoManager] init]:
NSLOg(@"Set Toolpicker");
NSLog(self->_toolPicker.isVisible ? @"yes" : @"NO"):
NSLog(self->_canvasview.isFirstResponder ? @"isFirstResponder: yes" : @"isFirstResponder: No");
]);
}
both _toolPicker.isVisible and _canvasview.isFirstResponder logged out to be "Yes"
Also, I'm running on ios's stimulator iphone 14 pro - ios 16.4 if that could be the issue.
Thanks in advance!