UIPageControl - iPhone Development - iphone

I have 5 pics to display (one at a time) in a UIPageControl way, so whenever i scroll (right or left) another pic will show. i can't find a sample code for that!
i searched a lot and apple's sample code is complicated i need a simpler one.

Actually what you are looking for is UIScrollView with pagination. UIPageControl is the small dots that is mostly(not necessarily) positioned on the bottom of scroll view. You have to configure it separately.
To enable paging in a scroll view, you need to set its pagingEnabled property to YES.
The following UIScrollView paging tutorial may help you.

Related

How to auto arrange all sub views?

I have a UITextView at the top of a UIView, below many UIControls are there like buttons, table view... Possibilities are user can give multiple lines in UITextView, in that case I have to expand(increase height) for UITextview to show two lines, If UITextview height increase every other controls should go down accordingly, How to do it in iOS ? I heard android they are auto arranging easily, Is there any way to do like this in iOS?
Where should I concentrate? Any ideas will be helpful. Thanx.
You should use autolayout for achieving this.
raywenderlich autolaout
developer.apple.com
Auto Layout video tutorial
About Cocoa Auto Layout
This tutorial helps you to understand autolayout in a better way.
You could look at auto layout, it's available from ios6 onwards. It will allow you to easily (some even non programmatically) specify constraints to be maintained while the view hierarchy is being displayed. For a good tutorial see this.
If you are working on iOS5 or below I would recommend the following :
I am assuming that all your views are direct children of the textView, even if that isn't the case the grandchildren views (and further ancestors) will move automatically once their parent moves down.
for (UIView* view in yourTextView.subviews)
view.transform = CGAffineTransformMakeTranslation(0,Y_DELTA_VALUE);
//Y_DELTA_VALUE is the amount you want to move the subviews down by, the
//(amount of height the textView increases by)/2

XCode iOS - home screen style navigation

Sorry this is a pretty silly question, but I cannot think what the actual menu style is called. I'm trying to find a tutorial on how to create a instructions page that you flick through left and right to see more instructions. Basically exactly how the home screen works with dots representing how many screens there are and which screen the user is on, plus the same animation where if you flick left/right the next one slides on.
If anyone knows what these are commonly referred to as I can go look up some tutorials.
Thanks a lot,
Chris
This control is called a UIPageControl. And here's a link to a tutorial.
Use a UIScrollview with pagingEnabled.
add a UIPageControl to the view (wherever you want to see the dots).
Instruction pages should be added as subviews to the UIScrollView
Make sure to use UIScrollView and UIPageControl delegates to update the page in the pageControl.
If you need more info on how to implement this, search with keywords UIScrollView and UIPageControl

UIScrollViews and Dynamically Creating Pages

I want to be able to dynamically populate UIScrollView. Like how it is done for row views in UITableView. I have a class that takes in some parameters and creates the respective view when it scrolls. Currently I have 8 views.
These 8 views have different background image, image and label according to the page number it is currently in. However the basic skeleton for this view is the same. What i am doing right now is in ViewDidLoad I am creating 8 views and add them as subviews and scroll over.
I don't want to do this. I want to create three views and the rest i want to populate when the user scrolls a page and then a page etc. How do i do this? ANy pointers/tutorial?
First of all you calculate the ContentSize for the scrollview (when you want to use the iPad in landscapemode with 8 pages then the width should be 1024*8 = 8192px and the height 768px).
Then you should implement the UIScrollView Delegate method:
scrollViewDidEndDecelerating:
In this Method you check on which page you currently are with the contentOffset property of the scrollview and start updating your left and right hidden views..
Hope this helps you a bit.
Check the two most recent WWDC videos for two excellent sessions regarding expert use of UIScrollViews. Additionally you can review a brief tutorial here, written by the well known cocoa expert, Matt Gallagher.

Special UIScrollView with multiple objects (3) on each page

What I want to accomplish is something like this:
Two different scrollViews, and each one scrolls horizontically. Each showing 3 images, and a half one (or 1/3th) piece of the next image in the datasource of the scrollview.
Does anyone know how to accomplish such a scrollview?
I also want to be able to tap an image to flip it and show some information and a button to the detail. (See lower scrollview).
Tapping it again would just show back the image, much like the coverflow ui inside itunes, but without the coverflow being 3D...
Any help is welcome :)
Thanks in advance,
Lewion
Scroll view doesn't have a datasource. What you are looking for is standard scrolling and nothing special.. So it is definitely doable... Check the scrolling and photo scroller sample codes from apple developer samples. For more implementations of scroll view check the scroll view suite sample code and read the scroll view programming guide.
The flip animation is also a standard animation for a view and is easily doable. For example, create a utility application for iphone. It has a flip side view. See how that animation is done.

Lazy loading of subViews into a non-paging UIScrollView

I am trying to implement a filmstrip-like UIScrollView that will be populated with thumbnails of catalog pages. Selecting a thumbnail image will cause the main UIScrollView to move to the selected page. The Catalog may contain 100 - 200 pages, and I want to load them lazily only when required.
I have done this in a UIScrollView with paging enabled, but haven't seen anything on the best way to do this in a non-paging scenario. There will be 6 thumbnails visible in the UIScrollView (+ 1 when the view is being scrolled) at any one time. I want to dequeue and reuse the thumbnail's UIView when the view is scrolled, as I am doing in the main UIScrollView (which is a paging scroll view).
Thanks -
Jk
I am also going to suggest you take a look at some sample code of Apple, that is, Photo Scroller. If you are a registered iOS developer, you should also take a look at the WWDC10 session about scroll views in iPhone applications.
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Listings/main_m.html
What you need to do is mimic the behavior of a table view (which is nothing more than a subclass of UIScrollView). What you should mimic is the reuse of the cells. It is pretty easy to implement and will dramatically reduce the memory foot print of your application since you only load the content that is currently visible in the scroll view.
I hope this helps.
Check out the scrollview suite sample code from apple. The tiled example can probably be repurposed very easily.
http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/
Check out this class..it may proove helpful..
VSScroller