Элемент UICollectionViewController не реагирует на действие щелчка после изменения значения UIRefreshControl
Я создал одноэкранное приложение с UICollectionViewController
внутри.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
TestCollectionViewController *testCollectionViewController = [[TestCollectionViewController alloc] initWithCollectionViewLayout:flowLayout];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:testCollectionViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
TestCollectionViewController
Сама реализация тоже очень проста. Имеет реализацию UICollectionViewDataSource
, UICollectionViewDelegate
а также UICollectionViewDelegateFlowLayout
протоколы. Также есть реализация UIRefreshControl
,
@implementation TestCollectionViewController
static NSString * const reuseIdentifier = @"Cell";
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.backgroundColor = [UIColor greenColor];
self.collectionView.alwaysBounceVertical = YES;
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.tintColor = [UIColor orangeColor];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Refreshing..." attributes:[NSDictionary dictionaryWithObject:[UIColor orangeColor] forKey:NSForegroundColorAttributeName]];
[refreshControl addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 10;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
return cell;
}
#pragma mark - UICollectionViewDelegate protocol methods
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@ cell selected!", @(indexPath.item)] message:@"Everything is great!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
#pragma mark - UICollectionViewDelegateFlowLayout protocol methods
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(self.collectionView.bounds.size.width, 75.0f);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsZero;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
return 1.0f;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return 1.0f;
}
- (void)refreshControlValueChanged:(UIRefreshControl *)sender
{
[sender endRefreshing];
}
@end
Когда приложение запускается на iPhone, все работает отлично
Когда действие управления обновлением запускается один раз, первая ячейка представления коллекции больше не реагирует на какие-либо действия.
Кто-нибудь раньше сталкивался с такой проблемой?