2015-03-15 10 views
5

enter image description here My utknął po przełączeniu kart, To dzieje się tylko na pierwszej karcie. Wewnątrz TabBar Mam 2 zakładki z UIViewControler wewnątrz, w którym mam UITableView.UIRefreshControl utknął po przełączeniu kart w UITabBarController z UIViewControler i UITableView

Próbowałem wszystkich rozwiązań sugerowanych HERE i nikt nie pracował dla mnie.

Poniżej przedstawiam, co robię.

- (void)viewDidLoad { 
[super viewDidLoad]; 

data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getData]]; 

[self addNavBar]; 
[self addDataTable]; 

//for refreshing the table data 
UITableViewController *tableViewController = [[UITableViewController alloc] init]; 
tableViewController.tableView = dataTable; 
refreshControl = [[UIRefreshControl alloc] init]; 
refreshControl.backgroundColor = [UIColor purpleColor]; 
refreshControl.tintColor = [UIColor whiteColor]; 
[refreshControl addTarget:self 
        action:@selector(refresh) 
     forControlEvents:UIControlEventValueChanged]; 
[dataTable addSubview:refreshControl]; 
tableViewController.refreshControl = refreshControl; 
} 


- (void)refresh { 
[self loadSentData]; 
data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getSentData]]; 
[self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO]; 
} 

- (void)reloadData{ 
[dataTable reloadData]; 
[refreshControl endRefreshing]; 
} 
+0

Jakie jest pożądane zachowanie? Czy utknie tam i nigdy nie zniknie? – gabbler

+0

Zwykłe zachowanie to 'tableview' (dataTable) wraca do tej samej pozycji, a' refreshView' znika. Jest to również pożądane zachowanie. – user1324887

+0

Więc utknął tam i nigdy nie odejdzie? – gabbler

Odpowiedz

0

Od tego pytania oglądano setki razy. Dodanie mojego rozwiązania może pomóc komuś innemu.

W moim przypadku było to spowodowane refreshControl. potrzebujesz oddzielnego refreshControl dla obu widoków. W końcu utworzyłem refreshControlFirstView i refreshControlSecondView i to rozwiązało problemy.

Powiązane problemy