UIRefreshControl一式两份出现

时间:2013-11-14 18:01:17

标签: xcode uiscrollview uirefreshcontrol

有人知道为什么myscrollview会重复显示UIRefreshControl吗?

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

1 个答案:

答案 0 :(得分:0)

问题是你在viewDidLayoutSubviews创建了这个视图,可以多次调用。如果您希望在视图中只有一个刷新控件,则应创建它并将其添加到viewDidLoad中的视图中,该视图在加载视图控制器时仅被调用一次。