猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互

本文主要是介绍猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

猫猫分享,必须精品

原创文章,欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243

一:效果

后面的是xcode的控制台
这里写图片描述

二:代码

ViewController

#import "ViewController.h"
#import "ColorsViewController.h"@interface ViewController () <ColorsViewControllerDelegate, UIPopoverControllerDelegate>
- (IBAction)buttonClick:(UIButton *)btn;
@property (nonatomic, weak) UIButton *colorButton;
@property (nonatomic, strong) UIPopoverController *popover;
@property (weak, nonatomic) IBOutlet UIButton *greenButton;- (IBAction)greenButtonClick;
@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];}- (IBAction)greenButtonClick {NSLog(@"greenButtonClick");
}- (IBAction)buttonClick:(UIButton *)btn {// 0.内容ColorsViewController *colors = [[ColorsViewController alloc] init];colors.delegate = self;// 1.创建self.popover = [[UIPopoverController alloc] initWithContentViewController:colors];self.popover.delegate = self;// 2.显示
//    [self.popover presentPopoverFromRect:CGRectMake(150, 150, 100, 100) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];[self.popover presentPopoverFromRect:CGRectMake(924, 668, 100, 100) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//    [self.popover presentPopoverFromRect:btn.bounds inView:btn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
//    [self.popover presentPopoverFromRect:btn.frame inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];// 3.设置哪里控件在popover显示出来的时候,仍旧可以跟用户进行交互self.popover.passthroughViews = @[self.greenButton];self.colorButton = btn;
}#pragma mark - 颜色选择代理
- (void)colorsViewController:(ColorsViewController *)vc didSelectColor:(UIColor *)color
{self.colorButton.backgroundColor = color;// 关闭popover[self.popover dismissPopoverAnimated:YES];
}#pragma mark - popover的代理
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{NSLog(@"popover销毁了");
}
@end

ColorsViewController

#import <UIKit/UIKit.h>
@class ColorsViewController;@protocol ColorsViewControllerDelegate <NSObject>@optional
- (void)colorsViewController:(ColorsViewController *)vc didSelectColor:(UIColor *)color;
@end@interface ColorsViewController : UITableViewController
@property (nonatomic, weak) id<ColorsViewControllerDelegate> delegate;
@end
#import "ColorsViewController.h"@interface ColorsViewController ()@end@implementation ColorsViewController- (void)viewDidLoad {[super viewDidLoad];self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return 30;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{static NSString *ID = @"cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];if (!cell) {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];cell.selectionStyle = UITableViewCellSelectionStyleNone;}cell.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1.0];return cell;
}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{if ([self.delegate respondsToSelector:@selector(colorsViewController:didSelectColor:)]) {UIColor *color = [tableView cellForRowAtIndexPath:indexPath].backgroundColor;[self.delegate colorsViewController:self didSelectColor:color];}
}
@end

这篇关于猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1138332

相关文章

PHP应用中处理限流和API节流的最佳实践

《PHP应用中处理限流和API节流的最佳实践》限流和API节流对于确保Web应用程序的可靠性、安全性和可扩展性至关重要,本文将详细介绍PHP应用中处理限流和API节流的最佳实践,下面就来和小编一起学习... 目录限流的重要性在 php 中实施限流的最佳实践使用集中式存储进行状态管理(如 Redis)采用滑动

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

深入浅出Spring中的@Autowired自动注入的工作原理及实践应用

《深入浅出Spring中的@Autowired自动注入的工作原理及实践应用》在Spring框架的学习旅程中,@Autowired无疑是一个高频出现却又让初学者头疼的注解,它看似简单,却蕴含着Sprin... 目录深入浅出Spring中的@Autowired:自动注入的奥秘什么是依赖注入?@Autowired

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

Nginx中配置使用非默认80端口进行服务的完整指南

《Nginx中配置使用非默认80端口进行服务的完整指南》在实际生产环境中,我们经常需要将Nginx配置在其他端口上运行,本文将详细介绍如何在Nginx中配置使用非默认端口进行服务,希望对大家有所帮助... 目录一、为什么需要使用非默认端口二、配置Nginx使用非默认端口的基本方法2.1 修改listen指令

PostgreSQL简介及实战应用

《PostgreSQL简介及实战应用》PostgreSQL是一种功能强大的开源关系型数据库管理系统,以其稳定性、高性能、扩展性和复杂查询能力在众多项目中得到广泛应用,本文将从基础概念讲起,逐步深入到高... 目录前言1. PostgreSQL基础1.1 PostgreSQL简介1.2 基础语法1.3 数据库

基于Java开发一个极简版敏感词检测工具

《基于Java开发一个极简版敏感词检测工具》这篇文章主要为大家详细介绍了如何基于Java开发一个极简版敏感词检测工具,文中的示例代码简洁易懂,感兴趣的小伙伴可以跟随小编一起学习一下... 目录你是否还在为敏感词检测头疼一、极简版Java敏感词检测工具的3大核心优势1.1 优势1:DFA算法驱动,效率提升10

MySQL按时间维度对亿级数据表进行平滑分表

《MySQL按时间维度对亿级数据表进行平滑分表》本文将以一个真实的4亿数据表分表案例为基础,详细介绍如何在不影响线上业务的情况下,完成按时间维度分表的完整过程,感兴趣的小伙伴可以了解一下... 目录引言一、为什么我们需要分表1.1 单表数据量过大的问题1.2 分表方案选型二、分表前的准备工作2.1 数据评估

Python中的filter() 函数的工作原理及应用技巧

《Python中的filter()函数的工作原理及应用技巧》Python的filter()函数用于筛选序列元素,返回迭代器,适合函数式编程,相比列表推导式,内存更优,尤其适用于大数据集,结合lamb... 目录前言一、基本概念基本语法二、使用方式1. 使用 lambda 函数2. 使用普通函数3. 使用 N