iphone开发4 一些小贴士。
来源:互联网 发布:淘宝投诉客服 编辑:程序博客网 时间:2024/06/01 14:42
1,获取翻转事件,并开启翻转:
只要在viewcontroller的类中加入
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
//翻转后要执行的代码
return YES;
}
2,-(void)viewWillAppear:(BOOL)animated,- (void)viewDidLoad 的区别。
viewwillappear是每次视图控制器的视图出现前执行的代码。而viewdidload是每次视图控制器载入是执行的代码。
比如说:当a视图控制器的视图第一次出现是两个都要执行,但当a被push后有pop回来时,只有viewwillappear执行。
3,如何让视图始终跟着手指移动,并有反弹事件
xsum=photopositon.origin.x+photopositon.size.width/2-touchstart.x;
ysum=photopositon.origin.y+photopositon.size.height/2-touchstart.y;
currentview.center=CGPointMake(xsum+p.x, ysum+p.y);
if (pow(currentview.center.x-160,2.0)>pow(photopositon.size.width/2, 2.0)||pow(currentview.center.y-240,2.0)>pow(photopositon.size.height/2, 2.0))
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
currentview.center=CGPointMake(160, 240);
[UIView commitAnimations];
}
就是让currentview的视图中心始终与手指保持一定的方位。
4,控制导航条和toolbar
[self.navigationController ...]
[self.navigationController.toolbar ...]
比如说让他们都消失:
[self.navigationController setToolbarItems:NULL animated:YES];
[self.navigationController.toolbar setBarStyle:UIBarStyleBlackTranslucent];
[self.navigationController setToolbarHidden:NO animated:YES];
5,自定义控件事件:
addTarget:self action:@selector(....) forControlEvents:....
比如获取某个按钮的触摸事件;
[new addTarget:self action:@selector(onChooseItem:) forControlEvents:UIControlEventTouchUpInside]
则当按钮按下时,- (void)onChooseItem:(id) sender 就会被调用。
sender传的就是被按下按钮的指针。
- iphone开发4 一些小贴士。
- iphone开发一些视频
- 一些iphone开发的资料
- 一些iphone开发的资料
- iphone开发一些学习网站
- iPhone开发的一些资源
- iPhone开发的一些资源
- iPhone开发一些小技巧
- [iphone] iPhone 开发过程中的一些小技术的总结
- [iphone] iPhone 开发过程中的一些小技术的总结
- iPhone Safari 开发中的一些特效样式
- iPhone 开发过程中的一些小技术
- iphone开发中的一些小技巧
- 转:iphone开发中的一些小技巧
- iphone开发中的一些小技巧
- iphone开发中的一些小技巧
- iphone开发中的一些小技巧
- iphone开发一些好的网站推荐
- 华视身份证阅读器SDK使用手册
- Linux--Sys_Read系统调用过程分析
- 从日常代码质量检查工作中感受工作中的乐趣、生活的乐趣
- Android应用程序开发环境的建立
- Android入门第十三篇之Gallery + ImageSwitcher
- iphone开发4 一些小贴士。
- Ruby gem 更新错误解决方案
- 我的博后申请经历从陶瓷到Offer过程
- 手把手教你配置OGRE v1.7
- 第二眼看Scrum
- android配置的错误
- 做个诚信的客户难,做个诚信的老板难,做个诚信的程序员更难,大家需要诚信的社会环境
- VS2008和VS2010安装顺序不能换
- 打酱油了。。。