IOS基础学习1
在此,我仅记录一些需要注意的知识点和一些需要复习才能记牢的地方。
@property关键字在声明变量的时候,对于int、float等原始数据类型,不需要制定任何可选属性(nonatomic,retain等),因为他们只是将int进行自定义数据类型:
typedef int NSInteger
当获得按钮的title时,需要确定按钮的状
态:
NSString *title = [sender titleForState:UIControlStateNormal];//正常状态下下的title
因为你可以设定当按钮处于不同状态下的时候,title所显示的内容。其他的状态:
UIControlStateHiglighted;高亮,就是按下的时候
UIControlStateDisabled;被禁用,表示按钮无法使用。
UIControlStateSelected;被选中,仅特定控件具有该状态(这个还不能理解,以后希望能碰到实例)
对于内存管理,我在论坛上询问一些朋友,答案模棱两可,但大概明白了
例如字符串对象NSString *string,若将其alloc,则你需要手动release他,若使用工厂方法如stringWithFormat,或直接为其赋值string=@“abc”,实际上,他们都是被放到自动释放池中了,你可以不用管他们,但这样操作必然没有手动释放更节约内存。
隐藏虚拟键盘的方法经常用,要记住:resignFisertResponder
分段控件中,selectedSegmentIndex要记住,等于0或1分别代表按下2个不同的按钮,以作判断。
actionSheet的按钮被按下时,可触发一个方法:-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex //当你按到哪个按钮可以写入不同的操作方法。
屏幕旋转方法:
-(BOOL)shouldAutorotateToInterfaceOrientations:(UIInterfaceOrientation)interfaceOrientation
return YES; //全都转
如需设定神马时候转,可以return interfaceOrentation
四个方向
UIInterfaceOrientationPortrait;
UIInterfaceOrientationPortraitUpsideDown;
UIInterfaceOrientationLandscapeLeft;
UIInterfaceOrientationLandscapeRight;
旋转开始时,旋转完成前可调用如下方法
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
CGRect *frame=CGRectMake(x,y,width,hight)
按钮美化
[button stretchableImageWithLeftCapWidth:12 topCapHeight:0];
posted on 2012-02-28 11:05 wangyutao0424 阅读(209) 评论(0) 编辑 收藏 举报