2013-11-14 46 views
0

任何人都知道爲什麼myscrollview顯示重複的UIRefreshControl?UIRefreshControl apile in duplicate

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

+0

你是否可能在一些被多次調用的方法中創建這個刷新控件?像viewWillAppear或類似的? –

+0

- (void)viewDidLayoutSubviews 什麼是最好的函數來初始化UIRefreshControl? – Pak

回答

0

的問題是,你正在創建這一觀點在viewDidLayoutSubviews,可多次調用。如果您希望在視圖中只有一個刷新控件,則應該創建該控件並將其添加到viewDidLoad中的視圖中,該視圖在加載視圖控制器時僅調用一次。