how to implement code for swapping the images? - iphone

hi all how to implement code for swapping the images if a row consists 10 images whenever we want swap the image by selecting the image clicking on that so help me to solve the problem in iphone

Asuming that images are in scrollview
First of all set image on uibutton and add target to that button to handle button click.
on button click set content offset of scrollview like this
[scrollview setContentOffset:CGPointMake(btn.frame.origin.x, 0) animated:YES];

Related

UIScrollView with UIImageView gesture click only work on first visible images

I have UIScrollView and I add few UIImageView, it's comment ViewController and click on images only work for first two images or for only images which are visible when scroll Y = 0. Even if image is half visible when scroll Y = 0 then first half of image click works and second half when you try to click nothing happen. Any explanation?
I resolve it by implementing touch position on scroll and I handle click on image if it's clicked on image ...

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

How to put my 2 existing buttons to the foreground, they are now behind an imageview

The question is in the title.
There must be a simpel way to do this I guess?
There is an imageview on the screen, there doesn't have to be any interaction with it.
On the imageview I want 2 small buttons left and right but the buttons were created (and the code is written) before the imageview. How do I set this imageview to the background? :)
[self.view sendSubviewToBack:yourImageView];
You can add buttons as subview of imageview.
you can write below code for that:
[imageView addSubview:button1];
[imageView addSubview:button2];
So buttons will be appear in foreground.
When looking at your xib or stoyboard (where you can see the layout), you can use the View Controller scene which is a list of all of the objects, views etc on your Apps layout.
You can click and drag the UI image view so its above the buttons in the list. I'm guessing it's just defaulted to being on top of the buttons.
In your storyboard, choose your viewController by clicking on it. On left side you can see hierarchy like left side view in this image. Check if your imageView is below, in hierarchy, to your 2 buttons. If it is, then drag the imageView and move it above both the buttons.
Concept : The view that is below in hierarchy is visible on top of all the views above it.

Setting UIScrollView position after each scroll

i have a scroll View which contains 10 images on a row.
the fiarst 5 items will display on the screen at first time
the remaining 5 images will display only after the scroll.
However ,I need to display only one image per each scroll.
Details
i have 10 images in my scroll view on a row.
1st,2nd,3rd,4th,5th images will dispaly at the firt time.
when first scroll is done , i need to dispaly the 2nd,3rd,4th,5th,6th images
after next scroll,i need to dispaly the 3rd,4th,5th,6th,7th images
after next scroll,i need to dispaly the 4th,5th,6th,7th,8th images etc.
is there any way to do it?
can any one provide me a good way.
Thanks
See the paging property in UIScrollView class.
Also you can stop scrolling in - (void)scrollViewDidScroll:(UIScrollView *)scrollView when image 6 will appear. After second scroll stop when image 7 will appear etc.
Setting UISCrollView Position:
[myScrollView scrollRectToVisible:CGRectMake(x,y,width,height) animated:NO];
I think that you use paging functionality for your case? If I right you can try making your scrollview less than the size of the screen (width-wise), but uncheck the "Clip Subviews" checkbox in IB. See more in this question.

How to slide button vertically in iphone?

How to slide button vertically in iphone by programmatically ?
Hey i have 7 images. and i want to display only 3 images vertically. and other images will be display when user scroll it upward.
Take a look at UIScrollView class :-) and then at UIImageView
If I understand what you want to do...
But we won't code you the thing ;-)
Good Luck.
add scrollview and setPagingEnabled =yes;
then
two way
1.add all images in view as subview and set the frame of them by one by one
2.in one view while scroll up add next image in view and remove old image.
right.Got it?
i think this tutorial will help you
http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/