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 ...
随机推荐
- HDU-2296 Ring(AC自动机+DP)
题目大意:给出的m个字符串都有一个权值.用小写字母构造一个长度不超过n的字符串S,如果S包含子串s,则S获取s的权值.输出具有最大权值的最小字符串S. 题目分析:先建立AC自动机.定义状态dp(ste ...
- java.lang.NoSuchMethodError: antlr.collections.AST.getLine()I错误解决
在J2EE框架下开发web网站,这种问题经常遇到,只要我们网上搜一下,就可以看到很多版本的,我整理一下: 第一种可能性解决:看看我的项目:主要 是里面的Structs 1.3 (structs 2)和 ...
- iOS_地图之显示附近微博
1.首先需要新建一个MKMapView地图对象,在storyBoard中拖拽一个,在工程中导入MapKit.framework: 2.遵守MKMapViewDelegate协议,设定显示地 ...
- 跟我学Windows Azure 五 使用Cloub Service连接Blob Service完成图片的上传
首先,我们创建一个云服务项目,用来演示我们的blob存储 下来我们修改我们我们云服务的名字 我们需要添加一个空的WebForm的项目 点击完成,我们可以看到我们的解决方案已经添加完成 下来我们需要添加 ...
- linux 删除进程的多种方法
kill pid kill -9 pid kill -15 pid pkill -f *.php kill -s 9 pid
- Today I learnt
2015-May-22 In Oracle database, dropping a table don't free up the space directly. You'll need to di ...
- JS 深度拷贝 Object Array
JS 深度拷贝 Object Array function cloneObj(o) { var isArray = o instanceof Array; var isObject = o insta ...
- IOS开发之--NSPredicate
我把常用的NSPredicate使用场景整理了一下 官方参考: https://developer.apple.com/library/mac/#documentation/Cocoa/Refer ...
- YII rules常见规则
public function rules() { return array( //必须填写 array('email, username, password, ...
- Intellij IDEA +MAVEN+Jetty实现Spring整合Mybatis
1 pom.xml(这里出现transaction错误,是版本的问题) <project xmlns="http://maven.apache.org/POM/4.0.0" ...