Tuesday, 20 August 2013

how to show popover with direction up or down relative to the button's current position

how to show popover with direction up or down relative to the button's
current position

Ok I have a scroll view added as a sub view with a height of approx. 500.
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(x,y,500,300)];
[self.view addSubView:scrollView];
Now I have another view say View1 which contains a lot of buttons arranged
in a vertical direction. View1's height is approx. twice the height of my
scrollView. View1 = [[UIView alloc]
initWithFrame:CGRectMake(0,0,100,300)]; [scrollView addSubView: View1];
now I set my scrollView's content size to fit in my View1. [scrollView
setContentSize: CGSizeMake(1000,300)];
Now able to scroll through my View1 completely. Now I need to show a
popUpViewController when a button within my View1 is pressed with a
direction up or down depending upon the button's current location. For
example if the button lies below the half way in my scrollView's frame,
the popOverViewController should pop up with an upward direction.
Now how do I get relative coordinates of the button to scroll View frame,
and if that button had an initial position below my scrollView's
frame.height.y/2 and after scrolling the button moved up say to a position
above my scrollView's frame.height.y/2, how do you get the relative
coordinates then. I have tried the convertRect: toView: but no success. I
hope you guys understand what i am trying to say here.

No comments:

Post a Comment