UIPopover 的简单用法
来源:互联网 发布:vb数字金字塔 编辑:程序博客网 时间:2024/06/06 00:30
popover是弹出窗口并不在页面具体存在
popover可以弹出UIview UITableView 等控制器所控制的页面所显示的内容
//下面是一个纯代码的演示 其中UINavigation 已经定义 但没有展示出来
#import "DetailViewController.h"
#import "SubTableViewController.h"
@interface DetailViewController ()
@property (nonatomic,strong)UIWebView *web;
//设置属性
@property (nonatomic,strong)UIPopoverController *pop;
@property (nonatomic,strong)UIBarButtonItem *btnRight;
@end
//导航栏barbutton的创建
UIBarButtonItem *rightBtn = [[UIBarButtonItemalloc]initWithTitle:@"选择语言"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(btnPress:)];
self.navigationItem.rightBarButtonItem = rightBtn;
self.btnRight = rightBtn;
//popover的内容控制器
SubTableViewController *tbVC = [[SubTableViewControlleralloc]init];
//popover的创建
UIPopoverController *pop = [[UIPopoverControlleralloc]initWithContentViewController:tbVC];
//popover的弹出窗口设定
pop.popoverContentSize =CGSizeMake(200,200);
self.pop = pop;
}
-(void)btnPress:(id)sender
{
//判断popover是否弹出并做相应的操作
if (self.pop.popoverVisible) {
//关闭页面
[self.popdismissPopoverAnimated:YES];
}
else
{
//设定弹出的位置及弹出的方向
[self.poppresentPopoverFromBarButtonItem:self.btnRightpermittedArrowDirections:UIPopoverArrowDirectionAnyanimated:YES];
}
}
#import "SubTableViewController.h"
@interface SubTableViewController ()
@property (nonatomic,copy)NSArray *arr;
@end
@implementation SubTableViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.arr =@[@"English",@"Chinese",@"French",@"Spanish"];
[self.tableViewregisterClass:[UITableViewCellclass] forCellReuseIdentifier:@"Cell"];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.arr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"Cell"forIndexPath:indexPath];
cell.textLabel.text =self.arr[indexPath.row];
return cell;
}
- UIPopover 的简单用法
- UIPopover使用不当引起的crash解决
- vi的简单用法
- fstream的简单用法
- namespace的简单用法
- qmake的简单用法
- AJAX的简单用法
- apt的简单用法
- JScrollPane的简单用法!
- iframe的简单用法
- UpdaeProgress的简单用法
- ScriptManager的简单用法
- CxImage的简单用法
- JScrollPane的简单用法!
- #import 的简单用法.
- string的简单用法
- ExternalInterface的简单用法
- maven 的简单用法
- 抓包
- Codeforces 633H. Fibonacci-ish II (Mo's Algorithm(莫队算法) + 线段树 + 离散化)
- Android中通过Tag为View保存数据绑定数据
- [leetcode 309]Best Time to Buy and Sell Stock with Cooldown--买卖股票with冷却期(DP法)
- iconv转换文件编码
- UIPopover 的简单用法
- Tomcat部署网站
- 小猫统计支持导入通达信数据到mysql了
- ubuntu发现wifi无法连接的解决方法
- 热块争用的解决方法(原创)
- Android应用开发性能优化完全分析
- 03.库的基本语法
- Android开发过程中eclipse不能打开虚拟机的情况
- 两个日期对象--可相减