我正在尝试实现StackScrollView(https://github.com/Reefaq/StackScrollView)在我的项目中,但是,我想要一堆从笔尖加载的视图,而不是一堆表视图。我创建了一个按钮并将其添加到rootViewController.m;
- (void)viewDidLoad {
[super viewDidLoad];
rootView = [[UIViewExt alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth + UIViewAutoresizingFlexibleHeight;
[rootView setBackgroundColor:[[UIColor scrollViewTexturedBackgroundColor] colorWithAlphaComponent:0.6]];
UIButton *buttonBar;
buttonBar = [UIButton buttonWithType:UIButtonTypeCustom];
[buttonBar setImage:[UIImage imageNamed:@"blue.png"] forState:UIControlStateNormal];
[buttonBar setImage:[UIImage imageNamed:@"gray.png"] forState:UIControlStateSelected | UIControlStateHighlighted];
buttonBar.frame = CGRectMake(9, 40, [UIImage imageNamed:@"www_gray.png"].size.width, [UIImage imageNamed:@"www_gray.png"].size.width);
[buttonBar addTarget:self action:@selector(newPage) forControlEvents:UIControlEventTouchUpInside];
[rootView addSubview:buttonBar];
}
这是buttonBar调用的方法:
-(void)newPage{
UIDetailController *paginaGenerica = [[UIDetailController alloc] initWithNibName:@"UIDetailController" bundle:nil];
[[StackScrollViewAppDelegate instance].rootViewController.stackScrollViewController addViewInSlider:paginaGenerica invokeByController:self isStackStartView:FALSE];
}
当我第一次按下按钮时,一切都很好。但是,当我再次触摸它时,我收到的是:
2012-01-23 10:53:46.263 StackScrollView[1048:f803] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM removeObjectAtIndex:]: index 2147483648 beyond bounds [0 .. 1]'
*** First throw call stack:
事实上,当我尝试为rootView设置动画(使整个内容向右移动,稍后在特定视图上滑动时返回)超过1次时,我也会收到同样的消息。
但是,我在UIDetailController.m中添加了相同的按钮和方法(让自己的View在自己的上面添加新的View,就像tableViews在StackScrollView的原始实现上工作一样),然后,一切都很完美。
我认为问题出在"StackScrollViewController.m"内部,但是,我对编程有点陌生,所以,我不理解代码的相同部分。如果有人已经使用StackViewController并面临这种情况,可能会有所帮助。。。
谢谢。
当您第一次点击按钮时,进行以下更改
[[StackScrollViewAppDelegate instance].rootViewController.stackScrollViewController addViewInSlider:paginaGenerica invokeByController:self isStackStartView:**TRUE**];
以及每次连续点击paginaGenerica视图
[[StackScrollViewAppDelegate instance].rootViewController.stackScrollViewController addViewInSlider:paginaGenerica invokeByController:self isStackStartView:FALSE];