PopOut a middle Image in a UIScrollView contain many images - objective-c

I have problem in playing with the UIScrollView i am using a customImage Object class to display images on scroll view and event fire on each image i achived it all but i have to do a extra work on it as the giving image showing that the middle image is pop out and fire event for that popout image...
i am confuse in it can anyone tell me how to achive this ....
please told me some steps to start with it..

You should be implementing the UIScrollViewDelegate protocol in the controller which should be handling the UIScrollView.
In there you will get a plethora of delegate callbacks such as when the scrollView moves or is decelerating towards a complete stop etc.
"UIScrollViewDelegate iOS reference"
You can implement any of the methods to suit your exact needs and modify the image's properties. To find which image is in the middle you would be comparing the contentOffset property of the scroll view o image locations.

Related

PDFView getting/setting scroll position

Good Morning,
I have a PDFView in an NSSplitView. I've implemented zooming and scrolling, using trackpad gestures. However whenever I reload the PDF, the scroll position resets to the top left corner. This is ok if the full page is shown, but if the PDF is zoomed and only partly visible, this can move the section of interest out of the view.
I've tried using enclosingScrollView but that returns nil. I've tried digging through the subviews to find the NSScrollView, the NSScrollers, NSClipView many of the displayRect and related properties are readonly. I've tried reading the verticalPageScroll and verticalLineScroll but they only every return 10.0.
I seem to be left with systematically going through the class properties and methods of each subview and see if they contain the data.
I'm sure someone knows how to get and set this.
Thanks.
Mark

Objective C draw in view dynamically

I have seen many examples of views being subclassed to override drawRect, but that approach is pretty static (at least as far as I understand).
What I'd like to do is set up a very simple drawing canvas. In that, I've got a view with a UIPanGestureRecognizer attached to it. Whenever the gesture fires a new position, I'd like to draw a circle of a fixed size and color in that position of the view. The gesture recognizer is attached to the view, but it fires a selector in the view controller. I already have a subclass of a UIView. So, what would be the best approach?
Thanks.
What you need to do in this case is still to override drawRect!
The difference is that you, when recognising gestures, need to keep track of the location(s) in which this circle should be drawn, and access that information the next time you are redrawing the view, essentially building up an image in memory that you draw into the view.

Gesture recognizer for tap event at specific positions on the screen

I am displaying hundreds of thumbnails in my view . I know default way to handle tap on thumbnail is using UICollectionView delegate method "didSelectItemAtIndexPath" but since its many thumbnails i wanted to look into adding gestures to the screen position so when i tap on a particular spot on the screen, it will handle the event accordingly for that particular thumbnail underneath. I would like to know if it is a good/possible approach?
It would be a hell of a lot easier to use a UICollectionView.
If you need a custom layout then you can subclass UICollectionViewLayout and get some really cool dynamic layouts.
You also get the added bonus of dequeued cells meaning that you get better memory management using it.
You may find UIGestureRecognizer useful. A good tutorial to get you started is here.

Programmatically resizing and Scrolling NSView after application launch

I want to create a simple application which performs some calculations and then draws some images on view. I use NSBezierPath. Then I must resize the view and allow people scroll the finished picture. But i don't know how.If I also try to draw an image on an invisible part of canvas then it becomes invisible or isn't drawn (I couldn't know the future canvas size).
Check out the Apple sample code called BezierPathLab. I think that will get you started. There's lot of other sample code for Quartz 2D drawing too.
Being able to scroll and resize the view should be as simple as putting the view that you will be using to draw inside an NSScrollView.

IKImageView zooming controlled by an NSSlider

What's the best practice for setting zoom factor of an image within IKImageView via NSSlider?
I was able to bind a slider either to zoom in OR zoom out action of an IKImageView.
Obviously, what I'd rather see is a single slider controlling both those actions.
Best, if image is refreshed after each change of the slider (continuously, even if a mouse button is not released yet).
This demo explains a lot: ImageKitDemo
In particular, this snippet is what I was looking for:
- (IBAction) zoomSliderDidChange:(id)sender
{
[addProductPhotoImageView setZoomFactor:[sender floatValue]];
}
The Bindings way would be to bind both the Zoom Factor of the IK image view and the Value of the slider to the same property of your controller. When the slider changes the value of the property, the image view will be notified, and will go get the new value from your controller.
One advantage of this way is that you can add more ways of zooming in and out and the value in the slider won't go stale. For one example, if IKImageView adds pinch-zooming (or if it has it already—I don't have multi-touch on my Mac), the user can zoom that way and the slider will update automatically. That won't happen with the IBAction solution.
Another example would be Zoom In and Zoom Out menu commands (perhaps with ⌘+ and ⌘- keyboard shortcuts) that send action messages to your controller. Your controller would respond by increasing or decreasing the value of the property (using a setter method it implements). With Bindings, both the image view and the slider will update for free. Without Bindings, you would have to explicitly talk to both the image view and the slider, telling one to update its zoom factor and the other to update its slider.
A third example would be a “Zoom factor: X%” display in a corner of your window. With Bindings, this can update for free no matter how the user zooms the image: moving the slider thumb, pinching/unpinching the image, or pressing a menu item. Without Bindings, this would be yet another thing you have to talk to in your (at least three) change-the-zoom-value action methods.