UIPopoverPresentationController实现多级跳转

效果:

效果

简单介绍

Demo的效果如上图,由于是一个效果展示的Demo其中有一些部分写的比较随意,数据部分是写的一个本地的json文件,需要修改地方根据自身项目修改

用UIPopoverPresentationController的好处在于,可以根据返回数据层级进行任意层级的处理

关键代码

此处只有一点比较关键的代码,具体代码看Demo

1
2
3
4
5
6
7
8
UIPopoverPresentationController *popController = [navCtrl popoverPresentationController];
popController.delegate = self;
popController.sourceView = self.popButton;
CGRect btnFrame = self.popButton.frame;
/// sourceRect的起点是从sourceView左上角
popController.sourceRect = CGRectMake(0, btnFrame.size.height, btnFrame.size.width, 1);

Demo

Demo