How to launch a ViewController from a Non ViewController class?

后端 未结 7 1989
星月不相逢
星月不相逢 2020-12-22 09:48

the title says it all, i usually open ViewControllers like this

ListingViewController *listingView = [[ListingViewController alloc]init];
[self.navigationCon         


        
7条回答
  •  感情败类
    2020-12-22 10:23

    You need a view controller of some sort for pushing or presenting, there's no way around that.

    You shouldn't have a problem accomplishing that and there are a few ways you can do so. First off, you should be able to write this logic in the UICollectionViewDelegate method collectionView:didSelectItemAtIndexPath:. Your delegate is most likely the containing view controller so that may be all you need to do. If however it isn't, just add a view controller property to your delegate that you can use for presenting things. Make it a weak one to avoid a possible retain cycle (where the view controller retains the delegate and the delegate retains the view controller).

提交回复
热议问题