سؤال

Anyone know why myscrollview show the UIRefreshControl in duplicated?

UIRefreshControl *refreshControl;
refreshControl = [[UIRefreshControl alloc]  initWithFrame:CGRectMake(0, 0, 20, 20)];
refreshControl.tintColor = [UIColor grayColor];
[refreshControl addTarget:self action:@selector(updateTableScroll:) forControlEvents:UIControlEventValueChanged];
[_myScrollView addSubview:refreshControl];
[refreshControl setAutoresizingMask:(UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleLeftMargin)];

[[refreshControl.subviews objectAtIndex:0] setFrame:CGRectMake(0, 50, refreshControl.frame.size.width, refreshControl.frame.size.height)]; //padding in Y axis

ImageLink-> https://dl.dropboxusercontent.com/u/14600481/Untitled-1.png

هل كانت مفيدة؟

المحلول

The problem is that you are creating this view in viewDidLayoutSubviews, which can be called multiple times. If you wish to only have one refresh control in your view, it should be created and added to the view in viewDidLoad which is called only once on loading the view controller.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top