0

I made a toolbar over a UIDatePicker and for it to look proper I had to move it up. After I did this the bar item stopped working and was unresponsive.

Working fine :

UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -29, 320, 22)];

Not working

UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -44, 320, 22)];

It also doesnt work at 30, so 29 must be the stopping point

1 Answers1

1

If the toolbar is a child (subview) of the picker, then it doesn't work because touches aren't registered outside of a view's (the picker) bounds.

You need to either create a common parent view to host both the toolbar and the picker within a single frame, or subclass the picker and do some hitTest: hackery to allow touches from outside the frame.

TomSwift
  • 39,369
  • 12
  • 121
  • 149
  • would this method work? `[pickerViewDate setBounds:CGRectMake` – user2654651 Aug 06 '13 at 21:31
  • Could you give me some more info on "create a common parent view". And how would I "do some hitTest: hackery to allow touches from outside the frame" – user2654651 Aug 06 '13 at 21:38
  • this question has a good overview: http://stackoverflow.com/questions/4961386/event-handling-for-ios-how-hittestwithevent-and-pointinsidewithevent-are-r – TomSwift Aug 06 '13 at 21:43
  • Am I doing something wrong? Because in all other tutorials, they all have it set to (0, 0, 320, 44) and if i do this it is in the middle of my datePicker? – user2654651 Aug 06 '13 at 21:57
  • Im new to programming and would like to stay as simple as possible. The hitTest thing looks way over me and I would like to do the common parent view. Could you give me a link for something on that? I have googled a lot and havn't found anything to do with this question. – user2654651 Aug 06 '13 at 22:02
  • The View Programming Guide is a good place to start: http://developer.apple.com/library/ios/#documentation/windowsviews/conceptual/viewpg_iphoneos/CreatingViews/CreatingViews.html – TomSwift Aug 06 '13 at 22:06