Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "MTResultsViewController.h"
- #import "MTGetResults.h"
- #import "NSDictionary+sortedKeys.h"
- #import "MTResultsCell.h"
- #import "MTResultCard.h"
- #import "MTDataLayer.h"
- @interface MTResultsViewController ()
- @property NSString *tab;
- @property int etapa;
- @property (nonatomic, strong) NSMutableArray *viewControllers;
- @end
- @implementation MTResultsViewController
- //@synthesize tableView, swipeView, pageControl;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateResults) name:@"resultsUpdate" object:nil];
- [MTGetResults getResults];
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- //configure swipe view
- _swipeView.alignment = SwipeViewAlignmentCenter;
- _swipeView.pagingEnabled = YES;
- _swipeView.wrapEnabled = NO;
- _swipeView.itemsPerPage = 1;
- _swipeView.truncateFinalPage = YES;
- //configure page control
- _pageControl.defersCurrentPageDisplay = YES;
- // Uncomment the following line to preserve selection between presentations.
- // self.clearsSelectionOnViewWillAppear = NO;
- // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
- // self.navigationItem.rightBarButtonItem = self.editButtonItem;
- [super setViewTitle:@"Screen title];
- }
- -(void)updateResults{
- [_swipeView reloadData];
- _pageControl.numberOfPages = _swipeView.numberOfPages;
- }
- - (NSInteger)numberOfItemsInSwipeView:(SwipeView *)swipeView
- {
- // Get the count of the current tab
- NSDictionary *resultsDictionary = [[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"];
- return [resultsDictionary count];
- }
- - (UIView *)swipeView:(SwipeView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
- {
- view = [[MTResultCard alloc] initWithFrame:_swipeView.frame];
- NSDictionary *resultsDictionary = [[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"];
- NSString *key = [[[[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"] allKeysSorted] objectAtIndex:index];
- // view.item = [[[[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"] objectForKey:key] objectAtIndex:index];
- ((MTResultCard *)view).item = [[[MTDataLayer sharedDataLayer].results objectForKey:@"mykey"] objectForKey:key];
- return view;
- }
- - (void)swipeViewCurrentItemIndexDidChange:(SwipeView *)swipeView
- {
- //update page control page
- _pageControl.currentPage = swipeView.currentPage;
- }
- - (void)swipeView:(SwipeView *)swipeView didSelectItemAtIndex:(NSInteger)index
- {
- // NSLog(@"Selected item at index %i", index);
- }
- - (IBAction)pageControlTapped
- {
- //update swipe view page
- [_swipeView scrollToPage:_pageControl.currentPage duration:0.4];
- }
- - (IBAction)campionat:(id)sender {
- [[NSNotificationCenter defaultCenter]postNotificationName:@"championshipUpdate" object:nil];
- }
- - (IBAction)cupa:(id)sender {
- [[NSNotificationCenter defaultCenter]postNotificationName:@"coupeUpdate" object:nil];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)viewDidUnload {
- [self setPageControl:nil];
- [super viewDidUnload];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment