iphone开发笔记退回输入键盘-(BOOL)textFieldShouldReturn:(id)textField{[textFieldresignFirstResponder];}CGRectCGRectframe=CGRectMake(origin.x,origin.y,size.width,size.height);矩形NSStringFromCGRect(someCG)把CGRect结构转变为格式化字符串;CGRectFromString(aString)由字符串恢复出矩形;CGRectInset(aRect)创建较小或较大的矩形(中心点相同),+较小-较大CGRectIntersectsRect(rect1,rect2)判断两矩形是否交叉,是否重叠CGRectZero高度和宽度为零的/位于(0,0)的矩形常量CGPoint&CGSizeCGPointaPoint=CGPointMake(x,y);CGSizeaSize=CGSizeMake(width,height);设置透明度[myViewsetAlpha:value];(0.0value1.0)设置背景色[myViewsetBackgroundColor:[UIColorredColor]];(blackColor;darkGrayColor;lightGrayColor;whiteColor;grayColor;redColor;greenColor;blueColor;cyanColor;yellowColor;magentaColor;orangeColor;purpleColor;brownColor;clearColor;)自定义颜色UIColor*newColor=[[UIColoralloc]initWithRed:(float)green:(float)blue:(float)alpha:(float)];0.0~1.0竖屏320X480横屏480X320状态栏高(显示时间和网络状态)20像素导航栏、工具栏高(返回)44像素隐藏状态栏[[UIApplicationshareApplication]setStatusBarHidden:YESanimated:NO]横屏[[UIApplicationshareApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight].屏幕变动检测orientation==UIInterfaceOrientationLandscapeLeft全屏window=[[UIWindowalloc]initWithFrame:[UIScreenmainScreen]bounds];自动适应父视图大小:aView.autoresizingSubviews=YES;aView.autoresizingMask=(UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);定义按钮UIButton*scaleUpButton=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[scaleUpButtonsetTitle:@放大forState:UIControlStateNormal];scaleUpButton.frame=CGRectMake(40,420,100,40);[scaleUpButtonaddTarget:selfaction:@selector(scaleUp)forControlEvents:UIControlEventTouchUpInside];设置视图背景图片UIImageView*aView;[aViewsetImage:[UIImageimageNamed:@”name.png”]];view1.backgroundColor=[UIColorcolorWithPatternImage:[UIImageimageNamed:@image1.png]];自定义UISlider的样式和滑块我们使用的是UISlider的setMinimumTrackImage,和setMaximumTrackImage方法来定义图片的,这两个方法可以设置滑块左边和右边的图片的,不过如果用的是同一张图片且宽度和控件宽度基本一致,就不会有变形拉伸的后果,先看代码,写在viewDidLoad中://左右轨的图片UIImage*stetchLeftTrack=[UIImageimageNamed:@brightness_bar.png];UIImage*stetchRightTrack=[UIImageimageNamed:@brightness_bar.png];//滑块图片UIImage*thumbImage=[UIImageimageNamed:@mark.png];UISlider*sliderA=[[UISlideralloc]initWithFrame:CGRectMake(30,320,257,7)];sliderA.backgroundColor=[UIColorclearColor];sliderA.value=1.0;sliderA.minimumValue=0.7;sliderA.maximumValue=1.0;[sliderAsetMinimumTrackImage:stetchLeftTrackforState:UIControlStateNormal];[sliderAsetMaximumTrackImage:stetchRightTrackforState:UIControlStateNormal];//注意这里要加UIControlStateHightlighted的状态,否则当拖动滑块时滑块将变成原生的控件[sliderAsetThumbImage:thumbImageforState:UIControlStateHighlighted];[sliderAsetThumbImage:thumbImageforState:UIControlStateNormal];//滑块拖动时的事件[sliderAaddTarget:selfaction:@selector(sliderValueChanged:)forControlEvents:UIControlEventValueChanged];//滑动拖动后的事件[sliderAaddTarget:selfaction:@selector(sliderDragUp:)forControlEvents:UIControlEventTouchUpInside];[self.viewaddSubview:sliderA];为了大家实验方便,我附上背景图brightness_bar.png和滑块图mark.png://pic002.cnblogs.com/images/2011/162291/2011121611432897.png-(IBAction)sliderValueChanged:(id)sender{UISlider*slider=(UISlider*)sender;NSString*newText=[[NSStringalloc]initWithFormat:@”%d”,(int)(slider.value+0.5f)];label.text=newText;}活动表单UIActionSheetDelegate-(IBActive)someButtonPressed:(id)sender{UIActionSheet*actionSheet=[[UIActionSheetalloc]initWithTitle:@”Areyousure?”delegate:selfcancelButtonTitle:@”Noway!”destructiveButtonTitle:@”Yes,I’mSure!”otherButtonTitles:nil];[actionSheetshowInView:self.view];[actionSheetrelease];}警告视图UIAlertViewDelegate-(void)actionSheet:(UIActionSheet*)actionSheetdidDismissWithButtonIndex:(NSInteger)buttonIndex{if(buttonIndex!=[actionSheetcancelButtonIndex]){NSString*message=[[NSStringalloc]initWithFormat:@”Youcanbreatheeasy,everythingwentOK.”];UIAlertView*alert=[[UIAlertViewalloc]initWithTitle:@”Somethingwasdone”message:messagedelegate:selfcancelButtonTitle:@”OK”otherButtonTitles:nil];[alertshow];[alertrelease];[messagerelease];}}动画效果-(void)doChange:(id)sender{if(view2==nil){[selfloadSec];}[UIViewbeginAnimations:nilcontext:NULL];[UIViewsetAnimationDuration:1];[UIViewsetAnimationTransition:([view1superview]?UIViewAnimationTransitionFlipFromLeft:UIViewAnimationTransitionFlipFromRight)forView:self.viewcache:YES];if([view1superview]!=nil){[view1removeFromSuperview];[self.viewaddSubview:view2];}else{[view2removeFromSuperview];[self.viewaddSubview:view1];}[UIViewcommitAnimations];}TableViewUITableViewDateSource#pragmamark-#pragmamarkTableViewDataSourceMethods//指定分区中的行数,默认为1-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSection:(NSInteger)section{return[self.listDatacount];}//设置每一行cell显示的内容-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{staticNSString*SimpleTableIndentifier=@SimpleTableIndentifier;UITableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier:SimpleTableIndentifier];if(cell==nil){cell=[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleSubtitlereuseIdentifier:SimpleTableIndentifi