0

For the accepted solution on this thread: How do you shrink a UIPickerView on the iPhone?

I can successfully re-size the picker. However I have TWO pickers in my controller. When I carry out the exercise for both pickers, they are re-sized, but when adding the transformed UIView to the main view, one of the transformed sub-views loses touch input. It's always the sub-view that is added FIRST that loses the touch input. how can i fix this?

Here is the code:

CGSize providerPickerSize = [providerPickerOutlet sizeThatFits:CGSizeZero];
CGSize amountPickerSize = [amountPickerOutlet sizeThatFits:CGSizeZero];

UIView *providerPickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, providerPickerSize.width, providerPickerSize.height)];
UIView *amountPickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, amountPickerSize.width, amountPickerSize.height)];

providerPickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);
amountPickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f);

[providerPickerTransformView addSubview:providerPickerOutlet];
[amountPickerTransformView addSubview:amountPickerOutlet];

[self.view addSubview:amountPickerTransformView];
[self.view addSubview:providerPickerTransformView];

Here the amountPickerTransformView loses touch input.

Using XCode 4.3, iOS 5 with storyboard.

Community
  • 1
  • 1
PhoenixDev
  • 746
  • 2
  • 9
  • 22

2 Answers2

0

Reason of losing touch on first added view is,

You are having two views of same frame one is providerPickerTransformView and other one is amountPickerTransformView.

now amountPickerTransformView is below the view providerPickerTransformView. so picker which add on amountPickerTransformView not taking the touch.

You need adjust frame of each view which contains picker appropriatley.

Ishu
  • 12,797
  • 5
  • 35
  • 51
0

Just change the x and y for the second view ie the view you want to the left side of the first view. As below

UIView *providerPickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, providerPickerSize.width, providerPickerSize.height)];
UIView *amountPickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(providerPickerSize.width, 0.0f, amountPickerSize.width, amountPickerSize.height)];

Happy Coding :)

EDIT 1

The problem as I can find in your code is

CGSize providerPickerSize = [providerPickerOutlet sizeThatFits:CGSizeZero];
CGSize amountPickerSize = [amountPickerOutlet sizeThatFits:CGSizeZero];

Replace CGSizeZero in those two lines with

CGSizeMake(CGFloat width, CGFloat height)

This will definitely solve your problem.

Happy Coding :)

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
  • The thing is, I'm using storyboard to put in the pickers. To re-size the pickers I have to put the full size picker on the storyboard in a funny position, for the re-sized picker to show in the proper place. Now when I implement your solution, or try to give the amountPickerTransformView any x coordinate other than 0.0f, it disappears completely. very confusing. – PhoenixDev Aug 08 '12 at 08:24
  • Have you tried to hard code the width in this code like in place of amountPickerSize.width put some hard coded value like 250 or what you want :)? – The iOSDev Aug 08 '12 at 08:27
  • Yes, for smaller values like 10.0 or 20.0 it is visible(sans touch), but for greater hard-coded values it disappears. – PhoenixDev Aug 08 '12 at 08:40
  • ok have to look at it and practically have to made one example for it and will post you the exact code for it :) – The iOSDev Aug 08 '12 at 08:46
  • Tell me that `providerPickerOutlet` and `amountPickerOutlet` what are these? Which type of iVar? :) – The iOSDev Aug 08 '12 at 09:32
  • Hi get the whole code from [here](https://www.dropbox.com/sh/s05zg3mxll7n1h1/kvIWrPs2iQ) – The iOSDev Aug 08 '12 at 10:18