I have started creating a simple product image carousel.
It basically comprises of 3 visible UIImageViews' and 2 hidden UIImateViews'.
The UIImageViews are populated with images from an array and animate to give the appearance of of a carousel.
My next objective is to determine which product the user taps and push a detail view onto the stack.
My question is how should I determine which product image was taped?
The complication comes in, in that the UIImageViews switch positions during the animation and are populated with different images as the users "Scrolls".
You can use the tag property of UIView to give the image views an identifier to recognize them by.
For example When you set image1 to imageView1, set the tag of imageView1 to be 1. If you set image500 to imageView1, set the tag to be 500. When an imageview is tapped, check it's tag to determine which image was tapped.
Related
I need some help on best direction for creating the following:
An Colours picker that shows a number of colours as small circles
Selected colour is a bigger circle
Allow user to click to select their colour
See image for example of what I mean
I am a bit lost in the best way to create this, I am not looking for the code it self just a direction to go by to create this :)
Using UICollectionView is the easiest available option.
1) Option 1
Use a custom UICollectionViewCell.
Add a view in it with constraints with respect to the superview i.e CollectionViewCell.
Give corner radius to the view to make it a circle.
On selection of the particular collectionViewCell, Update the size of the view and the corner radius to make the circle bigger.
Note : Save the indexPath of the previously selected cell if you want to decrease the size of the previously selected colour option.
2) Option2(Not suggested):
If the numbers of colours are limited. Use a stackView with buttons.
Customise the buttons to the required shape.
Updated the size of the button with respect to the superview i.e Stack.
You can have a single outlet for all the buttons. But you will have to save the instance of the selected button so as to update the previously selected button.
I'm writing a dictionary app to study iOS and I've implemented a UITableView with the alphabet as section titles and an index of all the letters on the right side. It works perfectly, but is it possible for me to display the selected index in a box at the center of the screen? I'm looking at the UITableViewDelegate reference but can't see any methods I might override. Help?
You'd have to manually create a UIView that you put above the UITableView which then shows the letter or whatever you want to present. Make sure not to add it to the table view itself as it's a UIScrollView subclass and your view would be affected by its contentOffset.
When the user presses one index or moves his finger above it, this callback gets called:
-tableView:sectionForSectionIndexTitle:title atIndex:
Use it to change your view's contents and make it visible and set a timer for it to fade out again.
You have to create custom view that display when you click on the cell and in that view you can add Label to show the alphabet which you have selected.
And yes also if you want to display it on center of your screen than give its X and Y coordinates value according to it.hope it helps...
I want to make an app which contains an image, and when a user
taps, a new image should come and hide a part of the old image.
For example, there is an image contains a table, when a user taps
a cell of the table, a new image should appear and cover the taped
cell along with all the cells that are to the right and below the
selected cell.
How can I do this ??
Thanks
Have a look at Core Animation.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
hi i am a new iphone programmer
i am creating a imagedisplay type application where i have to display images on a view and by presssing a next button a new image should appear on same view (i am using database)...
therefore i need to reload my current view again and again...each time when i click that button....
i tried some suggesion which are given on this website but not satisfied because many of them are based on timer...
please help.....
May be I have missed something in your question. But why you need to reload the entire view? You are using an UIImageView to display your image, right? And you are not showing any kind of scroll, but only a next button, right? Then why don't you just set the image property of UIImageView when the button is tapped.
// in button handler
myImageView.image = [UIImage imageNamed:#"new_image.png"];
Perhaps you could use a paged UIScrollView with three uIImageViews and always have the previous, current and next image loaded. This way when the user hits next, it scrolls animated to the next image. When page 3 is loaded, it programmatically sets the second image view as the desired next image, sets the image you came from on the first image view, and sets the scroll view non-animated to page two and loads the next image in the third image view.
Sounds complicated but basically you are giving the appearance of an infinite scroller but only pulling one image at a time except for initial load of three.
You could try looking at the "PageControl" Example Project in the XCode Documentation. It should give you a good starting point.
I am having trouble determining the tag of the view I am touching.
I have a scroll view and subclassed it in order to capture touch down events (I have pictures on the subview). However, I need to determine which picture I touched down.
I want to determine that tag of the subview, but I am getting random results (mostly tag 0). Whats the proper way of capturing this?
You can try using UIView hitTest. It will return you the subview the user is touching.