Display 2 images at the same time in UIScrollView - iphone

I'm quite new to iPhone development, and now dealing with a remote control app. Currently I can receive desktop image and perform simple mouse operations. But I still want to show a mouse pointer on my iPhone screen.
The desktop (very big, 1280X800) is in a image view which is the subview of a scroll view. Is there any way I can add a pointer image on top of the desktop image, and set it to any place I want? The pointer image do not receive any user interaction, it would be just floating on the desktop image.
Thank you very much for help.

Yes, just create a new UIImageView (or any other UIView subclass) with a frame based on where you want it to appear and add it to the scroll view's view using the addSubview: method. By default subviews you add later will appear above subviews you add earlier, but you can explicitly control which view appears on 'top' using 'bringSubviewToFront:'.

Related

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

iphone - Shrink image on scroll away in UIScrollView

So I have a UIScrollView in my app's menu. I have paging enabled and each page contains a button and an image. I would like to add a little animation where these start to shrink as they disappear off the screen (when the user scrolls to the next page).
I know I could do this by creating a property for each button and image and then manually changing the frame size in the scrollViewDidScroll method.
Does anyone have a more elegant solution so that I dont have to hard code each one in? It is possible that there's a predefined attribute for this or something?
Is each "page" in the scrollview actually a view or view controller? Whatever it is, hopefully it's an instance of some class, and thus reusable. Add a method to the custom view/view controller that uses the UIView animateWithDuration: methods to make the button and image shrink. Call that method when you determine that the scroll view has moved enough.

Changing View size using user touch input

I want to change my view size using user touch input.
What I know and will be trying is using TouchesMoved method and then finding the nearest vertex of the view to the touch, make the view increase in that direction using animation.
But there are few problems I have before I start.
1) The camera app has same functionality in cropping photo. There is a grid displaying actual crop area. I don't know how to display that grid. I don't have any knowledge of opengl. I would like to have that as a indication of user is in edit mode?
2) The camera app crop functionality is also of changing the size using user touch input but it only changes view size, if the touch is near the four vertices of the view. From what I know there is a method to check if the touch is in a specific rect CGRectContainsPoint but how do I filter it to bounds of the view?
Edit
I tried yinkou answer, downloaded from Git.
Now the real question is in the git Xcode project. There is a view which has image as a contentView and if user drag that view, the image also changes shape based on view resizing.
I am doing this in a camera app. I attached AVCaptureVideoPreviewLayer as a contentView. Now my view is resizing but the AVCaptureVideoPreviewLayer stays the same size. Am I doing something wrong or is it that AVCaptureVideoPreviewLayer won't increase?
And happily, there's a control out there:
https://github.com/spoletto/SPUserResizableView

Adding a viewController as subView programmatically

I am building an Iphone app.
I need to display a settings Menu to the user when a button is clicked. The menu will NOT be covering the whole screen and there is a specific location I want it to appear. How should I do that?
I understand how to set the hidden property of a subview to give the illusion that the subview is not onScreen. However, I need a view controller for this subview ( meaning .m and .h files as well). So How can I add this subview programmatically at a specific location.
Thank you very much
What you are describing is very much the behavior of a UIPopoverController. Unfortunately, that is only available for use on iPad's and not iPhone's or iPod Touches. So if you want to develop this you will need to develop this from scratch.
It's not a UI pattern you see much on the iPhone due to the screen size, but I imagine you will need to build up a custom UIView and add it the main window view with a specific size (smaller than screen size) and with the view's frame.origin set to a value other than (0,0).
Just make sure that what you are trying to achieve falls within Apple's Human Interface Guidelines.
[myView addSubview:myViewController.view];
myViewController.view.frame=...

Iphone Custom Scrollview indicator

I am currently working on an application for a client, and they have made an odd request. The request involves putting a custom image as the indicator for the scrollview. I am not even sure if this is possible but if it is can you please let me know how one would go about doing that.
Thanks
UIScrollView streches a small, semi-transparent circle image to generate its scrollbars. You can find this image as the first subview of a UIScrollView:
UIImageView *circle = [scrollView.subviews objectAtIndex:0];
However, as I said this image is stretched, and as far as I can tell, only the alpha values are considered when drawing the scroll bars.
So for example if you're only interested in changing the top/bottom ends of the scroll bar, you can try to change this image. However, I doubt you'll be able to do anything interesting.
A possible solution that comes to mind, and this is only a theory, is to add a custom, transparent UIView on top of a UIScrollView. Then you can hide the default scroll bar (by using showsHorizontalScrollIndicator and showsVerticalScrollIndicator), pass the necessary touch events to the UIScrollView to scroll the content, and draw the scrollbars in your custom view.