【问题标题】:Problem adding view to the end of my UIScrollView将视图添加到我的 UIScrollView 末尾的问题
【发布时间】:2011-04-06 05:40:18
【问题描述】:

我有一个包含一堆视图的 UIScrollView:

for(NSDictionary* deal in deals)
    {
        [items addObject:deal];

        DealViewController *dvc = [[DealViewController alloc] initWithNibName:@"DealViewController" bundle:nil];
        [dvc setNavigationController:[self navigationController]];
        UIView *dealView = [dvc view];
        [dealViewControllers addObject:dvc];

        //setup scrollView
        frame.origin.x = frame.size.width * i; 
        NSLog(@"Frame origin: %f", frame.origin.x);
        [dealView setFrame:frame];
        [scrollView addSubview:dealView];
        i++;
        [dvc displayDeal:deal];
    }

我想在滚动视图的最后添加一个视图,如下所示:

SignUpViewController* signUpView = [[SignUpViewController alloc] initWithNibName:@"SignUpViewController" bundle:nil];
[scrollView insertSubview:signUpView.view atIndex:[items count]];

signUpView 出现在 UIScrollView 的开头。怎么加到最后?

【问题讨论】:

    标签: iphone objective-c cocoa-touch uiview uiscrollview


    【解决方案1】:
    frame.origin.x = frame.size.width * i;
    [signUpView setFrame:frame];
    

    你没有告诉它在哪里画。

    【讨论】:

      【解决方案2】:

      试试

      [scrollView insertSubview:signUpView.view atIndex:[items count] - 1];
      

      如果您遇到问题,请告诉我

      【讨论】:

      • @Sheehan Alam:请检查 signUpView 的框架?
      猜你喜欢
      • 2021-06-05
      • 1970-01-01
      • 2012-03-11
      • 1970-01-01
      • 2014-01-30
      • 1970-01-01
      • 1970-01-01
      • 2016-07-25
      • 1970-01-01
      相关资源
      最近更新 更多