iphone UIKit类得中文讲解3

来源:互联网 发布:java c3p0连接池配置 编辑:程序博客网 时间:2024/06/06 14:22

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


父类:UIBarItemNSObject


定义文件: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则不显示任何图片。一般的,toolbarnavigationbar的图片要求为20x20


styleitem的风格


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;

原创粉丝点击