LoginSignup
0

More than 5 years have passed since last update.

UIRefreshControlのイベント内でUIAlertControllerを使ってメッセージを表示すると更新画像が表示されている領域が閉じなくなる

Last updated at Posted at 2017-02-24

表題の通りの問題。
半ば諦めていたけども、下記のようにすれば無事に解決。

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
                   action:@selector(onSwipeReloadData:)
         forControlEvents:UIControlEventValueChanged];        
self.myCollectionView.refreshControl = refreshControl;
// データが空でもUIRefreshControlを使えるようにする
self.myCollectionView.alwaysBounceVertical = YES;
- (void)onSwipeReloadData:(UIRefreshControl *)refreshControl
{
    [refreshControl beginRefreshing];

    *** なんかいろいろ処理 ***

    [self presentViewController:alert animated:YES completion: ^
    {
        // completion内で呼んでやればちゃんと閉じる!
        [refreshControl endRefreshing];
    }];
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0