多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > php開源 > 綜合技術(shù) > 【移動開發(fā)】操作表單_UIActionSheet

【移動開發(fā)】操作表單_UIActionSheet

來源:程序員人生   發(fā)布時間:2014-10-08 21:20:00 閱讀次數(shù):3811次

概述

如果要和UIActionSheet對象交互,那么UIViewController類的h文件需要遵循UIActionSheetDelegate協(xié)議。示例代碼:

 

@interface BIDViewController : UIViewController

 

并且,需要在UIViewController類的m文件中構(gòu)造一個UIActionSheet對象,同時實現(xiàn)協(xié)議的方法。示例代碼:

 

- (IBAction)buttonPressed:(id)sender { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?" delegate:self cancelButtonTitle:@"No Way!" destructiveButtonTitle:@"Yes, I’m Sure!" otherButtonTitles:nil]; [actionSheet showInView:self.view]; }

delegate參數(shù)就是UIActionSheet的委托對象,在這個例子中,傳入的selt就是BIDViewController對象本身,因為它實現(xiàn)了UIActionSheetDelegate協(xié)議。

調(diào)用showInView:方法,此處傳入BIDViewController對象的view實例,從而可以在BIDViewController的頁面上顯示出UIActionSheet。

 

 

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { if (buttonIndex != [actionSheet cancelButtonIndex]) { NSString *msg = nil; if (self.nameField.text.length > 0) msg = [NSString stringWithFormat: @"You can breathe easy, %@, everything went OK.", self.nameField.text]; else msg = @"You can breathe easy, everything went OK."; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Something was done" message:msg delegate:self cancelButtonTitle:@"Phew!" otherButtonTitles:nil]; [alert show]; } }
通過buttonIndex參數(shù)判斷點擊的是哪個按鈕。

 


該協(xié)議的描述。

The UIActionSheetDelegate protocol defines the methods a delegate of a UIActionSheet object should implement. The delegate implements the button actions and any other custom behavior. Some of the methods defined in this protocol are optional.

聲明了一些UIActionSheet的委托對象需要實現(xiàn)的一些方法。


該協(xié)議的源碼。

 

// // UIActionSheet.h // UIKit // // Copyright 2010-2012, Apple Inc. All rights reserved. // #import #import #import #import @protocol UIActionSheetDelegate; @class UILabel, UIToolbar, UITabBar, UIWindow, UIBarButtonItem, UIPopoverController; typedef NS_ENUM(NSInteger, UIActionSheetStyle) { UIActionSheetStyleAutomatic = -1, // take appearance from toolbar style otherwise uses 'default' UIActionSheetStyleDefault = UIBarStyleDefault, UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent, UIActionSheetStyleBlackOpaque = UIBarStyleBlackOpaque, }; NS_CLASS_AVAILABLE_IOS(2_0) @interface UIActionSheet : UIView { @private id _delegate; UILabel *_titleLabel; NSAttributedString *_attributedTitleString; UILabel *_subtitleLabel; UILabel *_bodyTextLabel; UILabel *_taglineTextLabel; CGFloat _startY; id _context; NSInteger _cancelButton; NSInteger _defaultButton; NSInteger _firstOtherButton; UIToolbar *_toolbar; UIWindow *_originalWindow; UIWindow *_dimWindow; NSInteger _suspendTag; NSInteger _dismissButtonIndex; CGFloat _bodyTextHeight; NSMutableArray *_buttons; NSMutableArray *_buttonsInTable; NSMutableArray *_textFields; UIView *_keyboard; UIView *_table; UIView *_buttonTableView; UIView *_dimView; UIPopoverController * _popoverController; CGFloat _fontSizeInTableView; // font size for 'complex' buttons (phone numbers || doc interaction controller) CGFloat _iconOffset; // doc interaction controller app icon CGFloat _labelOffset; // phone numbers layout CGFloat _labelWidth; CGFloat _titleWidth; BOOL _oldIgnoreTapsValue; struct { unsigned int numberOfRows:7; unsigned int delegateAlertSheetButtonClicked:1; unsigned int delegateDidPresentAlertSheet:1; unsigned int delegateDidDismissAlertSheet:1; unsigned int hideButtonBar:1; unsigned int alertStyle:3; unsigned int dontDimBackground:1; unsigned int dismissSuspended:1; unsigned int dontBlockInteraction:1; unsigned int sheetWasPoppedUp:1; unsigned int sheetWasShown:1; unsigned int animating:1; unsigned int hideWhenDoneAnimating:1; unsigned int layoutWhenDoneAnimating:1; unsigned int titleMaxLineCount:2; unsigned int bodyTextMaxLineCount:3; unsigned int runsModal:1; unsigned int runningModal:1; unsigned int addedTextView:1; unsigned int addedTableShadows:1; unsigned int showOverSBAlerts:1; unsigned int showMinTableContent:1; unsigned int bodyTextTruncated:1; unsigned int orientation:3; unsigned int popupFromPoint:1; unsigned int inPopover:1; unsigned int delegateBodyTextAlignment:1; unsigned int delegateClickedButtonAtIndex:1; unsigned int delegateClickedButtonAtIndex2:1; unsigned int delegateCancel:1; unsigned int delegateCancel2:1; unsigned int delegateWillPresent:1; unsigned int delegateWillPresent2:1; unsigned int delegateDidPresent:1; unsigned int delegateDidPresent2:1; unsigned int delegateWillDismiss:1; unsigned int delegateWillDismiss2:1; unsigned int delegateDidDismiss:1; unsigned int delegateDidDismiss2:1; unsigned int dontCallDismissDelegate:1; unsigned int useAutomaticKB:1; unsigned int twoColumnsLayoutMode:7; // one column || even width (leaves empty space) || first button wider || last button wider unsigned int threeColumnsLayoutMode:7; // one column || even width (leaves empty space) || first button wider || last button wider unsigned int shouldHandleFirstKeyUpEvent:1; // when presenting with hardware KB we have to handle the first key up event we get so we don't end up repeating the last key unsigned int cancelWhenDoneAnimating:1; unsigned int useThreePartButtons:1; // phone numbers layout unsigned int useTwoPartButtons:1; // doc interaction layout unsigned int displaySelectedButtonGlyph:1; int indexOfSelectedButton:7; // default -1 (no checkmark) otherwise will display a checkbox (this for the airtunes action sheet) unsigned int useCustomSelectedButtonGlyph:1; } _modalViewFlags; UIActionSheetStyle _actionSheetStyle; UIImage *_selectedButtonGlyphImage; UIImage *_selectedButtonGlyphHighlightedImage; UIImageView *_shadowImageView; } - (id)initWithTitle:(NSString *)title delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; @property(nonatomic,assign) id delegate; // weak reference @property(nonatomic,copy) NSString *title; @property(nonatomic) UIActionSheetStyle actionSheetStyle; // default is UIActionSheetStyleAutomatic. ignored if alert is visible // adds a button with the title. returns the index (0 based) of where it was added. buttons are displayed in the order added except for the // destructive and cancel button which will be positioned based on HI requirements. buttons cannot be customized. - (NSInteger)addButtonWithTitle:(NSString *)title; // returns index of button. 0 based. - (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex; @property(nonatomic,readonly) NSInteger numberOfButtons; @property(nonatomic) NSInteger cancelButtonIndex; // if the delegate does not implement -actionSheetCancel:, we pretend this button was clicked on. default is -1 @property(nonatomic) NSInteger destructiveButtonIndex; // sets destructive (red) button. -1 means none set. default is -1. ignored if only one button @property(nonatomic,readonly) NSInteger firstOtherButtonIndex; // -1 if no otherButtonTitles or initWithTitle:... not used @property(nonatomic,readonly,getter=isVisible) BOOL visible; // show a sheet animated. you can specify either a toolbar, a tab bar, a bar butto item or a plain view. We do a special animation if the sheet rises from // a toolbar, tab bar or bar button item and we will automatically select the correct style based on the bar style. if not from a bar, we use // UIActionSheetStyleDefault if automatic style set - (void)showFromToolbar:(UIToolbar *)view; - (void)showFromTabBar:(UITabBar *)view; - (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; // hides alert sheet or popup. use this method when you need to explicitly dismiss the alert. // it does not need to be called if the user presses on a button - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated; @end @protocol UIActionSheetDelegate @optional // Called when a button is clicked. The view will be automatically dismissed after this call returns - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; // Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button. // If not defined in the delegate, we simulate a click in the cancel button - (void)actionSheetCancel:(UIActionSheet *)actionSheet; - (void)willPresentActionSheet:(UIActionSheet *)actionSheet; // before animation and showing view - (void)didPresentActionSheet:(UIActionSheet *)actionSheet; // after animation - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex; // after animation @end

 

 

參考資料

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActionSheet_Class/

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIModalViewDelegate_Protocol/

https://developer.apple.com/library/IOS/documentation/UserExperience/Conceptual/UIKitUICatalog/UIActionSheet.html

生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 激情图片小说区 | 亚洲免费影院 | 图片小说亚洲 | yellow网站在线观看 | 亚洲福利在线观看 | 国产精品久久久精品视频 | 国产视频在线一区 | 免费观看欧美一级毛片 | 国产亚洲一区二区在线观看 | 波多野结衣一区2区3区 | 欧美日韩精品一区二区三区四区 | 欧美孕交videofree巨大 | 中文字幕乱码中文乱码综合 | 日韩高清无砖砖区2022 | 日韩性生活视频 | 精品视频在线看 | 中文字幕日韩精品中文区 | 亚洲 欧美 自拍 另类 欧美 | 国产午夜亚洲精品久久www | 美女无遮挡免费视频观看网站 | 香蕉狠狠再啪线视频 | 国产精品久久久久国产精品 | 欧美国产亚洲一区 | 国产欧美性综合视频性刺激 | 精品少妇一区二区三区视频 | 在线免费观看一级毛片 | 欧美日韩在线视频观看 | 中文字幕第4页 | 一级毛片特级毛片国产 | 国产极品嫩模在线观看91精品 | 亚洲欧洲一区二区三区 | 日本在线观看一区二区三区 | 中文字幕第十页 | 精品国产一区二区三区在线观看 | 亚洲黄色小说视频 | 国产区久久| 国产成人精品一区二三区在线观看 | 亚洲精品第一综合99久久 | 伊人影院在线视频 | 韩国欧美| 亚洲综合亚洲国产尤物 |