【问题标题】:"beyond bounds [0 .. 1]" message on StackScrollViewStackScrollView 上的“超出范围 [0 .. 1]”消息
【发布时间】:2012-01-23 13:12:42
【问题描述】:

我正在尝试在我的项目中实现 StackScrollView (https://github.com/Reefaq/StackScrollView),但是,我想要从 nib 加载的视图堆栈,而不是一堆表格视图。 我创建了一个按钮并将其添加到 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 并遇到过这种情况,可能会有所帮助...

谢谢。

【问题讨论】:

    标签: iphone objective-c ios ipad ios5


    【解决方案1】:

    当您第一次点击按钮时,请进行以下更改

    [[StackScrollViewAppDelegate instance].rootViewController.stackScrollViewController addViewInSlider:paginaGenerica invokeByController:self isStackStartView:**TRUE**];
    

    每次连续点击 paginaGenerica 视图

    [[StackScrollViewAppDelegate instance].rootViewController.stackScrollViewController addViewInSlider:paginaGenerica invokeByController:self isStackStartView:FALSE];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      • 1970-01-01
      相关资源
      最近更新 更多