UIAlertView類 (提醒警告視圖類)
父類:UIView:UIResponder:NSObject
定義檔案:UIAlert.h
類概述:使用這個類來彈出消息提示給使用者。一個消息警告視圖很像但是又不同于一個動作表單(Action sheet)
你必須使用屬性和方法設定這個類的标題,消息,視圖代理和按鈕參數。你必須設定代理當你增加使用者按鈕時。這個代理必須從屬于(UIAlertViewDelegate)協定。并且使用Show方法來顯示這個提醒視圖。
屬性:
cancelButtonIndex:退出按鈕的索引值
delegate:UIAlertViewDelegate對象
firstOtherButtonIndex:預設值為-1
message:NSString*類型,顯示比标題更多更詳細的内容。
numberOfButtons:alert View中按鈕的個數(NSInteger)
titile:出現在接收者的标題欄中的标題
visible:決定接收者是否可見,BooL值
執行個體方法:
- (NSInteger)addButtonWithTitle:(NSString *)title
作用:增加一個用給定字元串為名字的新按鈕
傳回值:新按鈕的索引值
- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex
作用:傳回給定索引值對應按鈕的标題
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
作用:動态釋放接收者
- (id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle
otherButtonTitles:(NSString *)otherButtonTitles, ...
作用:使用參數初始化并傳回一個alert view對象
UIApplication類 (全局應用程式類)
父類: UIResponder:NSObject
定義檔案:UIApplication.h
類概述:
屬性:
applicationIconBadgeNumber 用于設定應用程式圖示臨時跳闆标記的applicationIconBadgeNumber
delegate:UIApplicationDelegate協定
idleTimerDiable :設定應用程式是否在一定時間後關閉螢幕@property(nonatomic, getter=isIdleTimerDisabled) BOOL idleTimerDisabled 一般地圖應用,遊戲或者類似的需要使用者不定時互動的程式可以關閉這個idle timer(閑置計時)
keywindow:UIWindow *類型 應用程式的關鍵視窗
networkActivityIndicatorVisible:BOOL類型,關閉或者打開網絡活動的屬性。
使用:在應用程式需要網絡活動的時候設定為YES,否則為NO。預設為NO。
proximitySensingEnabled:決定是否可以近距離傳感。如果允許則為:YES,否則為:NO。允許近距離傳感高速iphone os當使用者的臉貼近時螢幕将變模糊或者空白。預設近距離傳感是不可行的。
statusBarFrame:狀态條的定義
statusBarHidden
statusBarOrientation
statusBarOrientationAnimationDuration:狀态欄做90度或者180度旋轉時的持續時間。
statusBarStyle:狀态條的風格
windows:NSArray *數組類型,儲存應用程式的可見視窗
類方法:
+ (UIApplication *)sharedApplication
作用:傳回UIApplicationMain所建立的應用程式的執行個體;
執行個體方法:
- (void)beginIgnoringInteractionEvents
作用:告訴接收者推遲捕捉觸摸關聯事件,你可以在開始一個動作或過渡前調用這個方法。
- (void)endIgnoringInteractionEvents
作用:通知接收者恢複捕捉觸摸關聯事件,你可以在動作或者過渡完成後調用這個方法。
- (BOOL)isIgnoringInteractionEvents
作用:YES時接收者正不響應使用者互動事件,NO則為正在響應互動事件。
- (BOOL)openURL:(NSURL *)url
作用:打開指定的位址
url(universal Resource Locator):支援 http,https;tel:,和mailto:
傳回值:YES為成功打開NSURL對象所指定的位址,NO為打開失敗。
- (BOOL)sendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event
作用:發送一個由selector定義的動作消息給一個特殊目标。
action:selector 定義的一個動作方法。
target:接收動作消息的對象。如果值為nil,則程式将這個消息發送給第一個響應者,從它的根源出發直到它被捕獲。
sender:動作消息的發送對象。
event:一個包含了動作消息起源資訊的UIEvent對象
傳回值:如果動作消息被成功抓獲則為YES,否則NO。
- (void)sendEvent:(UIEvent *)event
作用:派送一個事件給程式中适當的響應對象,子類可以重寫這個方法來截獲事件來實作特殊的派送。
- (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated
作用:隐藏或者顯示狀态欄,動态設定過渡
- (void)setStatusBarOrientation:(UIInterfaceOrientation)interfaceOrientation animated:(BOOL)animated
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated
UIBarButtonItem類
父類:UIBarItem:NSObject
定義檔案:UIBarButtonItem.h
類概述:包含了添加到UIToolbar和UINavigationBar對象的屬性和動作的項。
屬性:
action :當使用者使用這個按鈕時發送給目标對象的動作消息。
customView:代表這個項的使用者視圖
possibleTitle:可能顯示在這個Bar上的标題的集合 類型為NSSet*
style:項的風格
target:當這個項被選中時收到這個動作消息的對象
width:這個項的寬度
執行個體方法:- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action
作用:建立并傳回一個新項并且包含系統項
systemItem:系統項選擇使用作為bar上的第一項
target:接收這個動作消息的對象
action:消息發送到這個對象上來時選擇的動作(例如翻轉啊)。
- (id)initWithCustomView:(UIView *)customView
作用:使用使用者視圖的方式建立傳回一個新的項
customView:一個代表這個項的使用者視圖
- (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
image:顯示在bar上的圖檔,如果為nil則不顯示任何圖檔。一般的,toolbar和navigationbar的圖檔要求為20x20。
style:item的風格
target:接收這個動作消息的對象
action:當選中這項時産生的動作
- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
風格:
typedef enum { UIBarButtonSystemItemDone,:完成按鈕項UIBarButtonSystemItemCancel:系統的退出UIBarButtonSystemItemEdit:系統編輯按鈕UIBarButtonSystemItemSave:系統儲存按鈕
UIBarButtonSystemItemAdd, UIBarButtonSystemItemFlexibleSpace, UIBarButtonSystemItemFixedSpace, UIBarButtonSystemItemCompose, UIBarButtonSystemItemReply, UIBarButtonSystemItemAction, UIBarButtonSystemItemOrganize, UIBarButtonSystemItemBookmarks, UIBarButtonSystemItemSearch, UIBarButtonSystemItemRefresh, UIBarButtonSystemItemStop, UIBarButtonSystemItemCamera, UIBarButtonSystemItemTrash, UIBarButtonSystemItemPlay, UIBarButtonSystemItemPause, UIBarButtonSystemItemRewind, UIBarButtonSystemItemFastForward,
} UIBarButtonSystemItem;