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 ...
随机推荐
- SQL Server 中存储过程的练习
建库建表建约束 插入数据 --建库建表建约束和插入测试数据 use bankDB go --1.完成存款,取款业务--存款 create proc usp_takeMoney ),),)=null,@ ...
- Search Insert Position
int searchInsert(int* nums, int numsSize, int target) { ; ); ; int mid; while(low<=high){ mid=(lo ...
- FreeBSD Opera Flash问题
环境:FreeBSD 10,Opera,kldload linux 有些地方还是需要 flash 阿,但按照 Handbook 里面安装了 linux-f10-flashplugin11 和 oper ...
- flask请求管道
请求管道,登录前的验证,否则重定向到登录页面. # coding: utf8 from flask import render_template, request, g, session, redir ...
- Python 获得对象内存占用内存大小 sys.getsizeof
from sys import getsizeof class A(object): pass class B: pass for x in (None, 1, 1L, 1.2, 'c', [], ( ...
- Linux java环境安装
一.jdk yum 安装方法 1.wegt http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260 ...
- XSS的原理分析与解剖
0×01 前言: <xss攻击手法>一开始在互联网上资料并不多(都是现成的代码,没有从基础的开始),直到刺的<白帽子讲WEB安全>和cn4rry的<XSS跨站脚本攻击剖析 ...
- SQL 存储过程中QUOTED_IDENTIFIER on/off
http://huihai.iteye.com/blog/1005144 在存储过程中经常会有 SET QUOTED_IDENTIFIER on SET QUOTED_IDENTIFIER off S ...
- 警告:隐式声明与内建函数'exit'不兼容解决方案
警告:隐式声明与内建函数'exit'不兼容解决方案 #include <stdio.h> int main() { printf("hello world!/n"); ...
- [2014.01.27]wfPng 水印贴图组件 2.1
支持载入bmp,jpg,gif,png四种格式等. 支持图片水印使用png格式,支持区域透明,半透明的png图片. 支持图片缩放. 支持画线.画矩形.画椭圆,画正圆等图形. 支持在图片上输出文字. 能 ...