UIScrollSlidingPages
UIScrollSlidingPages copied to clipboard
TTSlidingPagesController reloadPages doesnt work
It doesnt remove the intial view added while i load another view to it.
initially i have set an array with 3 viewcontroller classes and added to it and saved in userdefault
-(int)numberOfPagesForSlidingPagesViewController:(TTScrollSlidingPagesController *)source{ return 3; //just return 7 pages as an example }
-(TTSlidingPage )pageForSlidingPagesViewController:(TTScrollSlidingPagesController)source atIndex:(int)index{
UIViewController *viewController;
if (index== 0){ //just an example, alternating views between one example table view and another.
viewController = [array objectAtIndex:0];
} else if (index== 1){
viewController = [array objectAtIndex:1];
}else{
viewController = [array objectAtIndex:2];
}
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:array];
[userDefault setObject:myEncodedObject forKey:[NSString stringWithFormat:@"array_ViewControllers"]];
NSLog(@"array %@",array);
return [[TTSlidingPage alloc] initWithContentViewController:viewController];
}
from another view controller class i called a method
-(void)MethodSetUp{
array=[[NSMutableArray alloc] init];
NSData *myDecodedObject = [[NSUserDefaults standardUserDefaults] objectForKey: [NSString stringWithFormat:@"array_ViewControllers"]];
array =[NSKeyedUnarchiver unarchiveObjectWithData: myDecodedObject];
// [self.slider.view reloadInputViews];
[self.slider reloadPages];
}
while reloading it doesnt calls its datasource method say
-(int)numberOfPagesForSlidingPagesViewController:(TTScrollSlidingPagesController *)source;
-(TTSlidingPage )pageForSlidingPagesViewController:(TTScrollSlidingPagesController)source atIndex:(int)index; -(TTSlidingPageTitle )titleForSlidingPagesViewController:(TTScrollSlidingPagesController)source atIndex:(int)index;
Hey!
Your code looks very strange. How come you're storing your view controllers in user defaults? That seems like a very odd thing to do? I would probably try and avoid doing that if possible. But in either case, I can't see where you actually add anything to array
anyway? I can see where you save it but not where you add anything to it?
But in terms of figuring out what's going on here, I would stick a breakpoint on [self.slider reloadPages];
in your MethodSetUp, and just make sure your array
is populated correctly with the right number of items that you're expecting, and also that self.slider
is not nil. Can you check these things first please?
Thanks, Tom
see i explain you
i haved added my view controller to an array and displayed when initial i want to display which is perfectly visible.
NSMutableArray *array=[[NSMutableArray alloc] init];
UIViewController *viewController= [[WomenViewController alloc] initWithNibName:@"WomenViewController" bundle:nil];
[array addObject:viewController];
UIViewController *viewController1 = [[MenViewController alloc] initWithNibName:@"MenViewController" bundle:nil];
[array addObject:viewController1];
UIViewController *viewController2 = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
[array addObject:viewController2];
NSUserDefaults *userDefault=[NSUserDefaults standardUserDefaults];
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:array];
[userDefault setObject:myEncodedObject forKey:[NSString stringWithFormat:@"array_ViewControllers"]];
i have added 3 view controller in starting and as you can see i have next button on the view which is yellow colored. by pressing next button i need to change my view controller class of index 0 only .
Please provide me with the solution how can i reload my views.
As the adding of view controllers in array is working perfectly fine.
in starting i add 3 view controller 2015-05-29 16:49:02.069 DemoDressUp[6246:119602] array ( "WomenViewController: 0x7fe81a646a20", "MenViewController: 0x7fe81a647320", "ChildViewController: 0x7fe81a6479a0" )
while pressing next i do replace by index 0 object in the array
array add ( "WomenSecondViewController: 0x7ffd007b1670", "MenViewController: 0x7ffd007b1af0", "ChildViewController: 0x7ffd007b29d0" )
but just the thing going wrong is reloading of view. can you please help me out with this.
Any update on this reload pages does not seems to work.
Hi Everyone, I'm facing the problem is how to limit pages on memory, because I'm adding a lot of ViewControllers to SlidingPages, when I'm scrolling some page it has become heavy. Please help me! Thank you so much!