2017-01-17 3 views
0

私はこのコード私が困惑リフレッシュを使用してセグエする方法ですよ何ランダムに目立たせる索引を使用して更新する?

let refreshControl = UIRefreshControl() 
refreshControl.addTarget(self, action: #selector(ViewController.refreshLoad), for: .valueChanged) 
    collectionViewIBO.addSubview(refreshControl) 

を使用して、私のCollectionViewにUIRefreshControlを設定しました。現在、私のモデルdatasource.model[indexPath.row]にはdidSelectItemAtを使用しています。私はInt(arc4random_uniform(UInt32(model.count)))を使用し、ランダムなインデックスを取得するために知っているこの関数の内部

func refreshLoad() { 

    print("refresh") 
    self.collectionViewIBO.reloadData() 


    stopRefresher() 
} 

にセグエするランダムなインデックスを選択することができるようにしたいです。しかし、私はこの機能をdidSelectItemAtと同じ動作をさせるためにどのように呼びますか?

+1

あなたの 'didSelectItemAt'の外観は何ですか? – toddg

答えて

0

同じ動作を探している場合は、なぜ引数としてindexPathをとる別個の関数を作成しないでください。

は、それを呼び出しいろいろ書いよう:

segueToUsing(indexPath : NSIndexPath) { 
    // Your current didSelectRowAt implementation 
} 

は、その後、あなたのdidSelectRowAtに単に与えられたindexPathで、この関数を呼び出します。そして、あなたのrefreshLoad機能で生成されたランダムindexPathでこれsegueToUsing関数を呼び出す:

let row = Int(arc4random_uniform(UInt32(model.count))) 
let indexPath = NSIndexPath(row: row, section: 1) 

これは、1つの実装の両方を解決します。

関連する問題