iPad 控件 UIPopoverPresentationController 使用 iPhone可用
- - (void)iPadAndIphonePopOver {
MenuViewController *menuVC = [[MenuViewController alloc] init];
menuVC.modalPresentationStyle = UIModalPresentationPopover;
menuVC.popoverPresentationController.sourceView = self.view;
menuVC.popoverPresentationController.sourceRect = self.testButton.frame;
menuVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[self presentViewController:menuVC animated:YES completion:nil];
}

code2:
* - (IBAction)popOver:(id)sender {
AddressViewController *contentVC = [[AddressViewController alloc] init];
contentVC.modalPresentationStyle = UIModalPresentationPopover;
contentVC.popoverPresentationController.sourceView = self.view;
contentVC.popoverPresentationController.sourceRect = CGRectMake(, , , );
contentVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[self presentViewController:contentVC animated:YES completion:nil];
}
* AddressViewController.m
* #import "AddressViewController.h" @interface AddressViewController () <UITableViewDelegate, UITableViewDataSource> @property (weak, nonatomic) IBOutlet UITableView *masterTableView; // 省份tableView
@property (weak, nonatomic) IBOutlet UITableView *detailTableView; // 地区tableView @property (nonatomic, strong) NSArray *masterDataSource; // 省份数据源
@property (nonatomic, strong) NSArray *detailDataSource; // 地区数据源
@property (nonatomic, assign) int masterIndex; // 选中的省份 @end @implementation AddressViewController - (void)viewDidLoad {
[super viewDidLoad]; _masterIndex = ;
self.preferredContentSize = CGSizeMake(, );
} - (NSArray *)masterDataSource {
if (_masterDataSource == nil) {
_masterDataSource = @[@"河南", @"河北", @"江苏", @"浙江", @"广东"];
}
return _masterDataSource;
} - (NSArray *)detailDataSource {
if (_detailDataSource == nil) {
_detailDataSource = @[@[@"郑州", @"洛阳", @"周口", @"开封"],
@[@"石家庄", @"石家庄2"],
@[@"南京", @"苏州", @"淮安", @"淮北", @"句容"],
@[@"杭州", @"温州", @"台州", @"宁波", @"瑞安", @"苍南"],
@[@"广州", @"深圳"]
];
}
return _detailDataSource;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView == self.masterTableView) {
return self.masterDataSource.count;
} if (tableView == self.detailTableView) {
return [self.detailDataSource[_masterIndex] count];
}
return ;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.masterTableView) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"master"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"master"];
}
cell.textLabel.text = self.masterDataSource[indexPath.row];
return cell;
} UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"detail"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"detail"];
}
cell.textLabel.text = self.detailDataSource[_masterIndex][indexPath.row];
return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == _masterTableView) {
_masterIndex = (int)indexPath.row;
self.preferredContentSize = CGSizeMake(, );
[_detailTableView reloadData];
} if (tableView == _detailTableView) {
self.preferredContentSize = CGSizeMake(, );
[_detailTableView reloadData];
}
} @end

- - (void)iPadAndIphonePopOver {
MenuViewController *menuVC = [[MenuViewController alloc] init];
menuVC.modalPresentationStyle = UIModalPresentationPopover;
menuVC.popoverPresentationController.sourceView = self.view;
menuVC.popoverPresentationController.sourceRect = self.test22.frame;
menuVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
menuVC.popoverPresentationController.delegate = self;
[self presentViewController:menuVC animated:YES completion:nil];
}
- - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
} - // 是否可以dismiss,返回YES代表可以,返回NO代表不可以
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
return NO;
}
iPad 控件 UIPopoverPresentationController 使用 iPhone可用的更多相关文章
- iPad 控件UIPopoverController使用
UIPopoverController 是iPad特有控件,(iOS7-9),在iOS9之后别废弃 使用步骤 设置内容控制器 UIPopoverController直接继承NSObject,不具备可视 ...
- js控件设置只读属性和不可用属性
介绍js实现只读的几种方法: 设置控件只读的话,我们要先清楚哪些没有readOlny这个属性 我知道的checkbox和RadioButton没有readOlny这个属性,我上一篇已经介绍了如何设置c ...
- 银联手机支付控件官方使用指南(ios版)
目录 版本信息... 2 目录 3 1 概述... 1 2 支付流程介绍... 1 3 测试帐号... 2 4 iOS客户端... 3 4.1 ...
- 认识基本的mfc控件
几乎可以在每个windows程序中都看到按钮.复选框.文本框以及下拉列表等等,这些都是控件.而且很多常用的控件已经内置到操作系统当中了,在Visual C++中,这些常用控件已经简答到能用“拖放”这种 ...
- 初识Windows窗体(包括各种控件,属性,方法)
什么是Wind ows窗体? 顾名思义,win dows窗体就是将一些所必须的信息通过窗体的形式展示给客户看.例如:我们经常玩的QQ登陆界面,微信登陆界面,等等,都是以窗体的形式将信息展示给我们看的. ...
- ASP.NETserver控件使用之Reportviewer 报表
1. Reportviewer 报表 1.1. Reportviewer控件 注:本教程附2个事例: l 演练:在本地处理模式下将数据库数据源与 ReportViewer W ...
- asp.net textbox控件基础
asp.net有两种控件,一种是html控件,一种是asp控件,在说textbox控件之前,先看看按钮的两个命令oncommand和onclick.每次点击按钮后,都会提交命令,但是程序会首先执行Pa ...
- 百度地图隐藏缩放控件比例尺Logo
对于百度地图最新版V3.7.3,以前的隐藏控件方法失效,可用以下方法隐藏: 1.隐藏缩放控件: mMapView.showZoomControls(false); 2.隐藏比例尺: mMapView. ...
- RichEdit控件 SDK 参考手册
RichEdit控件 SDK 参考手册 摘要: 本文对Rich Edit控件底层消息机制进行了讲解,以期读者对Windows平台下的Rich Edit控件有一个更深入的认识,同时对于使用Win32 S ...
随机推荐
- ubuntu更新命令点点滴滴
ubuntu更新命令点点滴滴 一些非root的更新命令: sudo: sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一 ...
- python的or操作符连接多个字符串含义是什么?
研究odoo代码的时候发现其中有一行语句让人费解 self.rcfile = os.path.abspath( self.config_file or opt.config or os.environ ...
- 《C与指针》读后感
到目前为止,我已经读到了<C与指针>第十六章,总共十八章,接下来的章节内容分别是标准函数库.数据结构.以及C语言的运行环境,还没有完全做完练习就写这篇读后感原因有二,第一个当然是最主要的, ...
- 【Django】Django 定时任务实现(django-crontab+command)
一.编写自定义django-admin命令 注:利用django-admin自定义命令我们可以ORM框架对model进行操作,如:定时更新数据库,检测数据库状态..... Django为项目中每一个应 ...
- get------引用接口
关于引用接口 1. 通过get方式 2. String poiUrl="http://接口地址?接口ID=接口给你的ID&参数1=?&参数2=?&参数 ...
- Qt自定义事件的实现(转)
原文:http://blog.csdn.net/michealtx/article/details/6866094 初学Qt,用了Qt自带的事件,然后想怎么才能定义自己的事件呢?又如何使用自定义事件呢 ...
- visual studio 的Error List 显示乱码
复制到右键菜单如下: Severity Code Description Project File LineError 閿欒: 绋嬪簭鍖卌om.baidu.lbsapi.auth涓嶅瓨鍦? com. ...
- logrotate机制与原理[转载]
http://blog.lightxue.com/how-logrotate-works/ 日志实在是太有用了,它记录了程序运行时各种信息.通过日志可以分析用户行为,记录运行轨迹,查找程序问题.可惜磁 ...
- Eclipse启动tomcat时出现报错-拒绝访问
今天新建项目,当选择项目的发布路径为tomcat的路径时 启动tomcat出现如下错误: Publishing the configuration... Error copying file to D ...
- CenOS 7 安装wordpress
1:Centos安装 php和html yum install httpd -y yum install php -y 2:将 wordpress 拖到目录 /var/www/html 3:浏览器访 ...