Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTSlidingPagesController reloadPages doesnt work #41

Open
ghost opened this issue May 29, 2015 · 4 comments
Open

TTSlidingPagesController reloadPages doesnt work #41

ghost opened this issue May 29, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented May 29, 2015

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;

@TomThorpe
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented May 29, 2015

screen shot 2015-05-29 at 4 57 39 pm
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"]];

ios simulator screen shot 29-may-2015 4 50 13 pm
ios simulator screen shot 29-may-2015 4 50 19 pm

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.

@kunwarr
Copy link

kunwarr commented Oct 8, 2015

Any update on this reload pages does not seems to work.

@seasofttrimai
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants