美文网首页iOS UIKit框架学习
iOS-UIKit框架学习—UIActionSheet

iOS-UIKit框架学习—UIActionSheet

作者: Wynter_Wang | 来源:发表于2017-02-06 15:01 被阅读18次

使用UIActionSheet类可以把一套如何继续给定任务的替代品给用户。您还可以使用行动表,以提示用户确认是否有潜在危险的行动。该行动表包含一个可选的标题和一个或多个按钮,其中每个对应采取的行动。

@protocol UIActionSheetDelegate;
// iOS 2.0 - iOS 8.3可用 使用UIAlertController顶替
NS_CLASS_DEPRECATED_IOS(2_0, 8_3, "UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead") __TVOS_PROHIBITED
@interface UIActionSheet : UIView

// 初始化设置标题、代理、操作按钮
- (instancetype)initWithTitle:(nullable NSString *)title delegate:(nullable id<UIActionSheetDelegate>)delegate cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Use UIAlertController instead.");
// 代理
@property(nullable,nonatomic,weak) id<UIActionSheetDelegate> delegate;
// 标题属性
@property(nonatomic,copy) NSString *title;
// 操作栏的风格
@property(nonatomic) UIActionSheetStyle actionSheetStyle; // default is UIActionSheetStyleAutomatic.
// 在操作栏中添加自定义按钮
- (NSInteger)addButtonWithTitle:(nullable NSString *)title;
// 返回指定索引按钮的标题
- (nullable NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
// 操作栏的按钮数
@property(nonatomic,readonly) NSInteger numberOfButtons;
// 取消按钮的下标
@property(nonatomic) NSInteger cancelButtonIndex;
// 破坏那妞的下标
@property(nonatomic) NSInteger destructiveButtonIndex;
// 第一个更多按钮的下标
@property(nonatomic,readonly) NSInteger firstOtherButtonIndex;
// 接收器是否显示
@property(nonatomic,readonly,getter=isVisible) BOOL visible;
// 显示一个来自指定工具栏的操作栏
- (void)showFromToolbar:(UIToolbar *)view;
// 显示一个来自指定标签栏的操作栏
- (void)showFromTabBar:(UITabBar *)view;
// 显示一个来自指定BarButtonItem的操作栏
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated NS_AVAILABLE_IOS(3_2);
// 显示一个来自指定矩形的操作栏
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated NS_AVAILABLE_IOS(3_2);
// 显示一个来自指定视图的操作栏
- (void)showInView:(UIView *)view;

// 隐藏弹出框
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;

@end


__TVOS_PROHIBITED
@protocol UIActionSheetDelegate <NSObject>
@optional

// 点击按钮操作调用
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;

// 点击取消操作按钮调用
- (void)actionSheetCancel:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
// 即将弹出操作栏之前调用
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3)__TVOS_PROHIBITED;
// 操作栏弹出后调用
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
// 操作后将要隐藏的操作栏时调用
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
// 操作栏隐藏完成后调用
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;  // after animation

@end

// 操作栏风格
typedef NS_ENUM(NSInteger, UIActionSheetStyle) {
UIActionSheetStyleAutomatic        = -1,       // take appearance from toolbar style otherwise uses 'default'
UIActionSheetStyleDefault          = UIBarStyleDefault, // 默认
UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent, // 半透明黑色
UIActionSheetStyleBlackOpaque      = UIBarStyleBlackOpaque , // 不透明黑色
} __TVOS_PROHIBITED;

相关文章

  • iOS-UIKit框架学习—UIActionSheet

    使用UIActionSheet类可以把一套如何继续给定任务的替代品给用户。您还可以使用行动表,以提示用户确认是否有...

  • iOS-UIKit框架学习—UIDatePicker

    UIDatePicker类实现了一个对象,它使用多个旋转的车轮,以允许用户选择日期和时间。iPhone的例子是一个...

  • iOS-UIKit框架学习—UITextView

    UITextView的类实现一个滚动的,多行文本区域的行为。类支持使用自定义字体,颜色,和对齐的文本的显示,同时还...

  • iOS-UIKit框架学习—UIScrollView

    UIScrollView的类提供支持显示的内容是大于应用程序的窗口大小。它可以使用户内滚动的内容,通过刷卡手势,和...

  • iOS-UIKit框架学习—UIAlertView

    使用UIAlertView类向用户显示一条警告消息。警报视图的功能相似,但在外观上不同于一个动作表(UIActio...

  • iOS-UIKit框架学习—UIAlertController

    UIAlertController对象向用户展示一个提示消息。这个类替换了用于显示提示 UIActionSheet...

  • iOS-UIKit框架学习—UITableView

    UITableView在iOS开发中是使用最广泛的一个控件,用于展示单个项目数据的列表,同时也可以进行选择和编辑操作。

  • iOS-UIKit框架学习—UIWebView

    您使用了UIWebView类,在您的应用程序中嵌入网页内容。要做到这一点,你只需创建一个UIWebView对象,将...

  • iOS-UIKit框架学习—UISearchBar

    UISearchBar类实现一个基于文本的搜索的文本字段控制。该控件提供了一个搜索按钮,输入文字的文本字段书签“按...

  • iOS-UIKit框架学习—UIWindow

    一个UIWindow对象提供了您的应用程序的用户界面的背景和提供了重要的事件处理行为。Windows没有自己的任何...

网友评论

    本文标题:iOS-UIKit框架学习—UIActionSheet

    本文链接:https://www.haomeiwen.com/subject/ngfuittx.html