猫猫分享,必须精品

原创文章,欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243

一:效果图

二:注意

对于方法[UIPopoverController dealloc] reached while popover is still visible.
当popover还在显示的时候,它就挂了
不允许popover还在显示的时候挂掉
popover必须在消失的时候挂掉

三:核心代码

- (IBAction)popMenu:(id)item {// 0.内容MenuViewController *menu = [[MenuViewController alloc] init];// 1.创建一个UIPopoverUIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:[[UINavigationController alloc] initWithRootViewController:menu]];// 2.设置尺寸
//    popover.popoverContentSize = CGSizeMake(320, 44 * 5);// 3.从哪里显示出来 --> 指向item[popover presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];self.popover = popover;
}

四:全部代码展示

ViewController

#import "ViewController.h"
#import "MenuViewController.h"@interface ViewController ()
- (IBAction)popMenu:(id)item;
@property (nonatomic, strong) UIPopoverController *popover;
@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];}// -[UIPopoverController dealloc] reached while popover is still visible.
// 当popover还在显示的时候,它就挂了
// 不允许popover还在显示的时候挂掉
// popover必须在消失的时候挂掉/***  弹出Popover菜单*/
- (IBAction)popMenu:(id)item {// 0.内容MenuViewController *menu = [[MenuViewController alloc] init];// 1.创建一个UIPopoverUIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:[[UINavigationController alloc] initWithRootViewController:menu]];// 2.设置尺寸
//    popover.popoverContentSize = CGSizeMake(320, 44 * 5);// 3.从哪里显示出来 --> 指向item[popover presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];self.popover = popover;
}
@end

MenuViewController

#import "MenuViewController.h"@interface MenuViewController ()
@property (nonatomic, strong) NSArray *titles;
@end@implementation MenuViewController- (void)viewDidLoad {[super viewDidLoad];self.titles = @[@"设置", @"清除缓存", @"退出", @"基本信息"];self.title = @"菜单";self.view.backgroundColor = [UIColor blueColor];CGFloat w = 320;CGFloat h = self.titles.count * 44;self.preferredContentSize = CGSizeMake(w, h);
//    self.contentSizeForViewInPopover = CGSizeMake(w, h);
}#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return self.titles.count;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{static NSString *ID = @"cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];if (!cell) {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];}cell.textLabel.text = self.titles[indexPath.row];return cell;
}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{UIViewController *vc = [[UIViewController alloc] init];vc.view.backgroundColor = [UIColor redColor];[self.navigationController pushViewController:vc animated:YES];
}@end

猫猫学iOS之ipad开发Popover的基本使用相关推荐

  1. iOS(iPhone,iPad))开发(Obje…

    原文地址:iOS(iPhone,iPad))开发(Objective-C)开发库常用库索引 作者:子木潇雨 http://www.code4app.com 这网站不错,收集各种 iOS App 开发可 ...

  2. 猫猫学IOS(四)UI之半小时搞定Tom猫

    话不多说 先上效果 项目源码素材下载地址: Tom猫游戏代码iOS 素材http://blog.csdn.net/u013357243/article/details/44457357 效果图 曾经风 ...

  3. (素材源代码)猫猫学IOS(四)UI之半小时搞定Tom猫

    下载地址:http://download.csdn.net/detail/u013357243/8514915 以下是执行图片展示 制作思路以及代码解析 猫猫学IOS(四)UI之半小时搞定Tom猫这里 ...

  4. 猫猫学IOS(六)UI之iOS热门游戏_超级猜图

    猫猫分享,必须精品 素材地址:http://blog.csdn.net/u013357243/article/details/44539069 原创文章,欢迎转载.转载请注明:翟乃玉的博客 地址:ht ...

  5. (素材源码) 猫猫学IOS(五)UI之360等下载管理器九宫格UI

    猫猫分享,必须精品 先看效果 代码学习地址: 猫猫学IOS(五)UI之360等下载管理器九宫格UI 猫猫学IOS(五)UI之360等下载管理器九宫格UI http://blog.csdn.net/u0 ...

  6. 猫猫学iOS 之微博项目实战(2)微博主框架-自己定义导航控制器NavigationController

    猫猫分享.必须精品 原创文章,欢迎转载.转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243? viewmode=contents 一:加入导航控制器 上一篇 ...

  7. 猫猫学iOS之最近的反思

    其实很早以前就想写点了,虽然猫猫现在还是学生,但是就自学方面,猫猫觉得自己水平还可以--注意,我不是大神,我只是一名小小的菜猫... 首先简单说一下自己吧,本人猫猫,真名看博客名字,目前大四,自学编程 ...

  8. iOS(iPhone,iPad))开发(Objective-C)开发库常用库索引

    http://www.code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例  http://www.cocoacontrols.com/ 英文版本的lib收集  ht ...

  9. 猫猫学iOS(五十五)多线程网络之图片下载框架之SDWebImage

    猫猫分享,必须精品 原创文章,欢迎转载.转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243?viewmode=contents 效果: 代码: - (NSA ...

最新文章

  1. Linux 操作系统原理 — 多处理器架构
  2. 红帽虚拟化RHEV-PXE批量安装RHEV-H
  3. C# .NET MVC 基础提供程序在 Open 上失败
  4. vue中如何使用mockjs摸拟接口的各种数据
  5. git使用.ignore忽略工程中的文件变动
  6. mysql大项目:新闻管理系统
  7. exchange2013卸载
  8. 把博客园的博客导出为MovableType的文本格式
  9. github 如何 只下载 一个项目中的 部分 代码文件
  10. 用 js 写的 WebSocketHeartBeat,心跳检测,断线重连
  11. win7系统下装ubuntu系统
  12. 火狐浏览器将网页保存为pdf
  13. 华为杯数学建模竞赛百分百获奖经验分享(获奖 == 四分经验,三分运气,三分实力)
  14. Vue2.0+Vue3.0全套教程
  15. 三层交换机配置实现不同网络互通
  16. axios请求发送两次请求_vue使用axios发送请求,都会发送两次请求
  17. 汇编语言复习~作业一(下)
  18. 大数据后从此再无隐私_大数据时代没有个人隐私?
  19. 2021年Java发展前景与职业方向分析!
  20. 痞子衡嵌入式:在IAR开发环境下将整个源文件代码重定向到任意RAM中的方法

热门文章

  1. 敏捷ios游戏创业分享:偏执者的战场
  2. python画松树_Python中的Phyllotaxis模式| 算法植物学的一个单位
  3. UGUI研究院之针对IOS平台设置某些图不打图集
  4. 【调剂】青岛大学2020年硕士研究生招生预调剂通知
  5. 基于深度学习的文本分类 3
  6. FX4300超频4.7GHz
  7. 装修找哪家装修公司?新房收房时有哪些注意事项?
  8. 推荐几个阿里、头条大佬的公众号
  9. few-shot NER 数据集 和普通NER数据集的区别与联系
  10. 2017年8月8日 星期二 --出埃及记 Exodus 28:30