【问题标题】:ScrollView jumps to the top of the page when change button backgroundImageScrollView在更改按钮backgroundImage时跳转到页面顶部
【发布时间】:2015-09-15 07:19:21
【问题描述】:

当我单击页面底部的按钮时,ScrollView 会跳转到页面顶部。当我始终单击页面底部的 uitexfield 时,也会发生这种情况。我能做些什么让它静止不动? 在 viewDidLoad() 中:

self.scrollView.pagingEnabled=NO;

在 iewDidLayoutSubviews 中:

  -(void)viewDidLayoutSubviews{
       [super viewDidLayoutSubviews];

   self.scrollView.frame=CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
   self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, 1150);


 }

问题是在此处更改按钮的 ImageBackground 时:

 - (IBAction)pressedData:(id)sender {


   if ( !self.checkDataIsPressed ) {
        self.checkData =true;
        [self.checkDataPerson setBackgroundImage:
        [UIImage imageNamed:@"check_on"]forState:UIControlStateNormal]; //the jumps scrollview is here
   }else{
        self.checkData =false;
       [self.checkDataPerson setBackgroundImage:
       [UIImage imageNamed:@"check_off"]forState:UIControlStateNormal]; //the jumps scrollview is here
    }

}

【问题讨论】:

  • 什么是视图做了布局子视图的方法,,,
  • 是动态高度的uiscrollview

标签: ios objective-c uiscrollview uibutton


【解决方案1】:

点击按钮

[scrollView setContentOffset:CGPointMake(320,0) animated:YES];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多