热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

UIActionSheet的各种属性、方法及代理的使用

2019独角兽企业重金招聘Python工程师标准#importActionSheetTestViewController.himplementationActionSh

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

#import "ActionSheetTestViewController.h"
@implementation ActionSheetTestViewController
/*
TasksCreating Action Sheets– initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: Setting Propertiesdelegate property title property visible property actionSheetStyle property 无例
Configuring Buttons– addButtonWithTitle: numberOfButtons property – buttonTitleAtIndex: cancelButtonIndex property destructiveButtonIndex property firstOtherButtonIndex property
Displaying– showFromTabBar: – showFromToolbar: – showInView:
Dismissing– dismissWithClickedButtonIndex:animated:
*/// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {UILabel *numOfBtn = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 10.0, 30.0, 30.0)];UILabel *titleOfBtn = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 10.0, 100.0, 30.0)];UILabel *cancelBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(200.0, 10.0, 30.0, 30.0)];UILabel *destructiveBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 50.0, 30.0, 30.0)];UILabel *firstOtherBtnIndex = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 50.0, 30.0, 30.0)];UIActionSheet *actionSheetTest = [[UIActionSheet alloc]initWithTitle:@"ActionSheetTest" delegate:selfcancelButtonTitle:@"CancelButton" destructiveButtonTitle:@"RedButton" otherButtonTitles:@"OtherButton1",@"OtherButton2",nil];//看actionSheet是否可见,这是一个只读属性BOOL a = actionSheetTest.visible;NSLog(@"%d",a);//不考虑指定索引的按钮的动作,可以设置是否有动画[actionSheetTest dismissWithClickedButtonIndex:0 animated:NO];//设置标题actionSheetTest.title = @"ActionSheetTitle";//通过给定标题添加按钮[actionSheetTest addButtonWithTitle:@"addButtonWithTitle"];//按钮总数numOfBtn.text = [NSString stringWithFormat:@"%d",actionSheetTest.numberOfButtons];//获取指定索引的标题titleOfBtn.text = [actionSheetTest buttonTitleAtIndex:4];//获取取消按钮的索引cancelBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.cancelButtonIndex];//获取红色按钮的索引destructiveBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.destructiveButtonIndex];//获取第一个其他按钮的索引firstOtherBtnIndex.text = [NSString stringWithFormat:@"%d",actionSheetTest.firstOtherButtonIndex];//设置actionSheet出现的方式[actionSheetTest showInView:self.view];//or [actionSheetTest showFromTabBar:] or [actionSheetTest showFromToolBar:][self.view addSubview:numOfBtn];[self.view addSubview:titleOfBtn];[self.view addSubview:cancelBtnIndex];[self.view addSubview:destructiveBtnIndex];[self.view addSubview:firstOtherBtnIndex];[actionSheetTest release];[numOfBtn release];[titleOfBtn release];[cancelBtnIndex release];[destructiveBtnIndex release];[firstOtherBtnIndex release];[super viewDidLoad];
}/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {// Return YES for supported orientationsreturn (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {// Releases the view if it doesn't have a superview.[super didReceiveMemoryWarning];// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {// Release any retained subviews of the main view.// e.g. self.myOutlet = nil;
}- (void)dealloc {[super dealloc];
}#pragma mark -- UIActionSheetDelegate --
//根据被点击按钮的索引处理点击事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {NSLog(@"clickedButtonAtIndex:%d",buttonIndex);
}
//ActionSheet已经消失时
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {NSLog(@"didDismissWithButtonIndex:%d",buttonIndex);
}
//ActionSheet即将消失时
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {NSLog(@"willDismissWithButtonIndex:%d",buttonIndex);
}
//
- (void)actionSheetCancel:(UIActionSheet *)actionSheet {NSLog(@"actionSheetCancel");}
//ActionSheet已经显示时
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet {NSLog(@"didPresentActionSheet%@",actionSheet);
}
//ActionSheet即将显示时
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {NSLog(@"willPresentActionSheet%@",actionSheet);
}@end


转:https://my.oschina.net/kevinvane/blog/129770



推荐阅读
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 展开全部下面的代码是创建一个立方体Thisexamplescreatesanddisplaysasimplebox.#Thefirstlineloadstheinit_disp ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 后台获取视图对应的字符串
    1.帮助类后台获取视图对应的字符串publicclassViewHelper{将View输出为字符串(注:不会执行对应的ac ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文介绍了一个Java猜拳小游戏的代码,通过使用Scanner类获取用户输入的拳的数字,并随机生成计算机的拳,然后判断胜负。该游戏可以选择剪刀、石头、布三种拳,通过比较两者的拳来决定胜负。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文讨论了如何在不使用SearchBar display controller的情况下,单独使用SearchBar并捕获其textChange事件。作者介绍了实际状况,即左侧SliderMenu中的SearchBar需要在主页TableView中显示搜索结果。然后,作者提供了解决方案和步骤,帮助读者实现这一功能。 ... [详细]
  • JDK源码学习之HashTable(附带面试题)的学习笔记
    本文介绍了JDK源码学习之HashTable(附带面试题)的学习笔记,包括HashTable的定义、数据类型、与HashMap的关系和区别。文章提供了干货,并附带了其他相关主题的学习笔记。 ... [详细]
author-avatar
勿缘无悔
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有