Unable to scroll within the DetailViewController's view


#1

Hello folks,

I’m curious why I can’t seem to scroll the DetailViewController’s view. The ImageView is clipped by the NavigationBar at the bottom, so I would expect to be able to drag the view up to see the rest of the image. What is needed to do that? Thanks for you help. Images below.

  • Max

Here’s an example of the image about to be chosen by the ImagePicker. It’s a picture of a jigger. Notice the gap between the jigger and the bottom of the bounds.

Here’s what the DetailViewController’s view looks like. The image is clearly cropped but I can’t drag up to see the rest.


#2

You would need to put either the whole view, or the image view inside a scroll view to do this.

Chapter 6 will give you the details you need to do this.

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk


#3

Thanks fujilla. I ended up doing the following:

  1. Put all the controls above the nav bar into their own UIView
  2. Make that UIView a UIControl to keep the ‘dismiss keyboard when clicking on background’ functionality
  3. Put the UIControl in a UIScrollView
  4. In viewDidLoad, set the UIScrollView’s content size

So the only code I added was


#4

[quote=“SkyPants”]Thanks fujilla. I ended up doing the following:

  1. Put all the controls above the nav bar into their own UIView
  2. Make that UIView a UIControl to keep the ‘dismiss keyboard when clicking on background’ functionality
  3. Put the UIControl in a UIScrollView
  4. In viewDidLoad, set the UIScrollView’s content size

So the only code I added was

Can you elaborate more on your (above) solution?


#5

[quote=“fujilla”]You would need to put either the whole view, or the image view inside a scroll view to do this.

Chapter 6 will give you the details you need to do this.

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk[/quote]

Fujila can you give more advice how to do this?

For example if I put ScrollView like this: ViewController.view --> ScrollView --> SomeIntermediaryViewWhereControllsAreAdded —> (buttons, text fields, etc.)

Then, this SomeIntermediaryViewWhereControllsAreAdded must also be able to dismiss the keyboard when user clicks outside keyboard area…but then where do I
put that code for resigning the responder?

which approach shall I take?


#6

If I understand your setup correctly you can change the Class of your ViewController.view xib file to UIControl in the Identity Inspection, then create a new IBAction method called something like backgroundTapped, and marry the ViewController.view up with this method.

Then when someone taps anywhere on the view it should dismiss the keyboard.

Nick