UIRefreshControl nakładki tekstowe na wskaźnik odświeżania

Zaczynam od programowania pod XCode 5 z iOS 7 SDK. A kiedy tworzę UITableViewController z UIRefreshControl z 'attributedText', mam tekst nałożony na grafikę UIRefreshControl (animacja postępu kółka).

Ale kiedy pociągnę w dół i zwolnię palec, tekst wskakuje do normalnej pozycji. Dlaczego to się stało?

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];

    self.refreshControl = refreshControl;

Przed ściągnięciem do końca:

Przed ściągnięciem do końca

Po UIRefreshControl release:

Po wydaniu UIRefreshControl

Author: Unheilig, 2013-09-27

3 answers

Proszę spróbować.

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Pull to Refresh"];
    [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;

    dispatch_async(dispatch_get_main_queue(), ^{
        [self.refreshControl beginRefreshing];
        [self.refreshControl endRefreshing];
    });

}
 27
Author: jeilsoft,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-27 08:54:21

Wywołanie layoutIfNeeded Po ustawieniu tytułu

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];
[self.refreshControl layoutIfNeeded];
 0
Author: Parag Bafna,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-07-08 12:05:48

Zmień kod na następujący

self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(updateDeviceList) forControlEvents:UIControlEventValueChanged];
self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Update Devices States"];

self.refreshControl = refreshControl;

To powinno rozwiązać twój problem

 -3
Author: CTiPKA,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-18 14:13:29