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 ...
随机推荐
- Oracle启动脚本,开机自启动设置
#!/bin/sh # chkconfig: # description: Oracle auto start-stop script. # # Set ORA_HOME to be equivale ...
- FizzBuzz 问题
public class FizzBuzz { static int start = 1; static int end = 100; public static void main(String[] ...
- Java中引用类型变量,对象,值类型,值传递,引用传递 区别与定义
一.Java中什么叫做引用类型变量?引用:就是按内存地址查询 比如:String s = new String();这个其实是在栈内存里分配一块内存空间为s,在堆内存里new了一个Stri ...
- C#对象克隆介绍
浅拷贝和深拷贝 有两种对象克隆的方法:浅拷贝和深拷贝.浅拷贝只是复制引用,而不会复制引用的对象.深拷贝会复制引用的对象. 因此,原始对象中的引用和浅拷贝对象中的同一个引用都指向同一个对象.而深拷贝的对 ...
- windows下使用ffmpeg进行视频转换和截图。
author:fanfq(xiaoban) Email:fangqing.fan#gmail.comlink:http://fanfq.iteye.com/admin/blogs/655569chan ...
- PHP list,explode的使用
PHP list,explode的使用 <?php header("Content-type: text/html; charset=utf-8"); echo " ...
- 怎样让SoapHttpClientProtocol不使用系统默认代理
方法很简单,但找起来很难. 使用SoapHttpClientProtocol类的Proxy属性. 不能设空值,必须设一个新值. 赶脚底层在链接的时候会判断这个属性是不是null,如果null就会用默认 ...
- 【学】React的学习之旅2 - React Component的生命周期
分成三个状态: Mounted Update Unmounted Mounted:当我们看到组件在浏览器中从无到有的效果的时候,mounted已经结束了,这个组件已经被mounted了 有这个阶段有2 ...
- UVA 1151 买还是建(最小生成树)
买还是建 紫书P358 [题目链接]买还是建 [题目类型]最小生成树 &题解: 这题真的心累,看了3天,最后照着码还是wa,先放lrj代码,以后再看吧 &代码: // UVa1151 ...
- [转]细说Redis监控和告警
原文 https://zhuoroger.github.io/2016/08/20/redis-monitor-and-alarm/? 对于任何应用服务和组件,都需要一套完善可靠谱监控方案. 尤其r ...