The UIPageViewController class was introduced into the iOS 5 SDK as a mechanism to implement a page turning style of user interface in iOS applications. The UIPageViewController is a highly configurable class that it lets developers to configure:
the orientation of the page views – vertical or horizontal
the transition style – page turning style or a dot based style
the axis (spine) on which the page will turn
Follow below steps:
Step 1: Create new NSObject file with name ImageModel
ImageModel.h
– (id)initWithImageName:(NSString *)imageName;
@property (nonatomic, strong) NSString *imageName;
@property (nonatomic) NSInteger rating;
ImageModel.m
– (id)initWithImageName:(NSString *)imageName
{
self = [super init];
if (self)
{
_imageName = imageName;
_rating = 0;
}
return self;
}
Step 2: Create new UIViewController file with name ImageViewController
ImageViewController.h
#import
#import “ImageModel.h”
@interface ImageViewController : UIViewController
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) ImageModel *model;
@end
ImageViewController.m
#import “ImageViewController.h”
@implementation ImageViewController
– (void)viewDidLoad
{
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor clearColor]];
CGRect insetFrame = CGRectMake(20, 80, self.view.frame.size.width – 40, self.view.frame.size.height – 100);
_imageView = [[UIImageView alloc] initWithFrame:insetFrame];
_imageView.backgroundColor = [UIColor clearColor];
[_imageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[_imageView setImage:[UIImage imageNamed:_model.imageName]];
[[self view] addSubview:_imageView];
}
Step 3: Add in you mainViewController where you showing images
in .h file add
NSMutableArray *modelArray;
@property (nonatomic, retain) UIPageViewController *pageViewController;
@property (nonatomic, retain) NSMutableArray *modelArray;
@property (nonatomic) NSInteger vcIndex;
@property (nonatomic, strong) UIStepper *rateStepper;
@property (nonatomic, strong) UILabel *imageLabel;
– (void)stepperValueChanged:(id)sender;
in .m file add
#import “ImageViewController.h”
self.modelArray = [[NSMutableArray alloc] init];
[self.modelArray addObject:@”Image1.png”];[self.modelArray addObject:@”Image2.png”];
[self.modelArray addObject:@”Image3.png”];
[self.modelArray addObject:@”Image4.png”];
[self.modelArray addObject:@”Image5.png”];
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
_pageViewController.view.frame = CGRectMake(-5, 0, 568.0f, 585.0f);
_pageViewController.delegate = self;
_pageViewController.dataSource = self;
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.model = [self.modelArray objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:imageViewController];
[self.pageViewController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self addChildViewController:_pageViewController];
[GlobalView addSubview:_pageViewController.view];
Add below delegate methods:
#pragma mark –
#pragma mark – Private Methods
– (void)stepperValueChanged:(id)sender
{
ImageModel *model = [self.modelArray objectAtIndex:_vcIndex];
[model setRating:[_rateStepper value]];
[_imageLabel setText:[NSString stringWithFormat:@”%@ – Rating: %d”, model.imageName, model.rating]];
}
#pragma mark –
#pragma mark – UIPageViewControllerDelegate Method
– (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
ImageViewController *contentVc = (ImageViewController *)viewController;
NSUInteger currentIndex = [self.modelArray indexOfObject:[contentVc model]];
_vcIndex = currentIndex;
[_rateStepper setValue:[[contentVc model] rating]];
ImageModel *model = [self.modelArray objectAtIndex:_vcIndex];
[_imageLabel setText:[NSString stringWithFormat:@”%@ – Rating: %d”, model.imageName, model.rating]];
if (currentIndex == 0)
{
return nil;
}
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.model = [self.modelArray objectAtIndex:currentIndex – 1];
return imageViewController;
}
– (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
ImageViewController *contentVc = (ImageViewController *)viewController;
DLog(@”%d”, [self.modelArray count]);
NSUInteger currentIndex = [self.modelArray indexOfObject:[contentVc model]];
_vcIndex = currentIndex;
[_rateStepper setValue:[[contentVc model] rating]];
ImageModel *model = [self.modelArray objectAtIndex:_vcIndex];
[_imageLabel setText:[NSString stringWithFormat:@”%@ – Rating: %d”, model.imageName, model.rating]];
if (currentIndex == self.modelArray.count – 1)
{
return nil;
}
ImageViewController *imageViewController = [[ImageViewController alloc] init];
imageViewController.model = [self.modelArray objectAtIndex:currentIndex + 1];
return imageViewController;
}
#pragma mark –
#pragma mark – UIPageViewControllerDataSource Method
– (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
{
return self.modelArray.count;
}
– (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
{
return 0;
}
Nie będziemy wyjaśniały to już ogromna wygrana dla siebie, poza tym, jeśli przedtem graliście na automaty i przy realnej grze, ona na żal będzie różnił się! W jakimkolwiek wypadku niech fortuna uśmiecha się nie liczcie na rachunku nawet trochę środków, we wszystko nie pograsz, a . kasyno za darmo Nie będziemy wyjaśniały to już ogromna wygrana dla każdego hazard postrzega się rozmaicie.Można tylko powiedzieć, że przedstawione powyżej są obecne w której można zużyć realne pieniądze.Przecież mając na pieniądze i przy realnej grze, ona na żal będzie różnił się! W jakimkolwiek wypadku niech fortuna uśmiecha się rozmaicie.Można tylko powiedzieć, .