Mega gold challenge issue


#1

I had seen a number of solutions to this challenge which simply define a UIView via a nib and present it in the DrawView. I wanted to take this into the drawViewController, so I created a paletteView and paletteViewController with a nib, laid out the color buttons in the nib, etc. I defined a paletteDelegate protocol to handle dismissing the modal view and communicating settings back to the invoking view. I then instantiated the swipe gesture in the drawViewController’s loadView, allowing me to target the drawView, but create the action on the drawViewController. In this action, ( swipeUp:) I i instantiate the paletteController via initWIthNibName:bundle. and present the view via [self presentViewController:animated:completion]. It all works will with one slight problem. I cannot, for the life of me, control the size of the paletteView which is presented. How does one go about forcing the size of the modal view? I have tried setting it explicitly in the nib, and even forcing the bounds after the fact. Here is how I am invoking it

// the following is the action on the drawViewController which is targeted by the swipe up gesture.


- (void)swipedUp:(id)sender {
    NSLog(@"Swiped up");
    paletteViewController *viewController = [[paletteViewController alloc] initWithNibName:@"paletteViewController" bundle:nil];
    viewController.delegate = self;
    
    [ viewController updateSelectedColor:self.drawView.selectedColor];
    [ viewController setSize:(ushort)self.drawView.selectedSize];
    viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    viewController.modalPresentationStyle = UIModalPresentationFormSheet;
    // present view
    [self presentViewController:viewController animated:YES completion:NULL];
    
    /*
     // tried to set the size based on the following advice, but it didn't work
     // https://coderwall.com/p/vebqaq
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
    navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:navigationController animated:YES completion:nil];
    navigationController.view.superview.frame = CGRectMake(0, 0, 480, 280);
    navigationController.view.superview.center = self.view.center;
     */
   
}

#2

I tried going down the same route, but it seems the modal view has to have the same size as the presenting view – at least without cumbersome workarounds. But then I read the challenge more carefully and realized it didn’t specify that the color-picker panel had to be smaller than the main view, so I let myself off the hook and allowed the presented view to be full-screen.