IOS开发经验分享
一些IOS开发的心得:
1) [Multiple Threads] IOS多线程注意, 所有的UI操作都必须在主线程上:
Any code that will update the UI should be done on the main thread. Data loading should typically be done in some background thread.
示例: [self performSelectorOnMainThread:@selector(updateThumbnail:) withObject:tmpImg waitUntilDone:false];
2) [Design] Three20是个重量级的框架,差不多是自己重新实现了IOS的UI组件, 使用需谨慎!
3) [Design] Single UIViewController or Mutiple UIViewController, need think~
4) [UI] 获取ipad/iphone的当前方向:
- UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
- if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
- ... ...
- } else {
- ... ...
- }
5) [Memory Management] Release a variable and set it to nil is a good habit.
- // 在viewDidLoad中alloc或者new的对象空间需要在这边释放
- - (void)viewDidUnload {
- [_sushiTypes release];
- _sushiTypes = nil;
- }
- - (void)dealloc {
- [_sushiTypes release];
- _sushiTypes = nil;
- [super dealloc];
- }
http://www.raywenderlich.com/2657/memory-management-in-objective-c-tutorial 写道
6) [Other] #import and @class declaration usage
7) [UIWebView] UIWebView 和 应用之间的交互
The Cocoa layer can also "intercept" link clicks by implementing the UIWebViewDelegate protocol in your view controller; when a link is clicked, the delegate method webView:shouldStartLoadWithRequest:navigationType: will be called, at which point the Cocoa layer can do the kind of "pop-up" action you're looking for.
(Although I would ask you why you want to generate pop-ups like this. My gut feeling tells me that this will look and feel quite annoying from the user's point of view.)
8) [UI] A great article for Popoverview usage
http://mobiforge.com/designing/story/using-popoverview-ipad-app-development
9) [Design] 由于UI操作是非线程安全的(需要在主线程上执行), 尽量减少异步的UI操作. 如果界面比较复杂可以考虑使用UIWebView
10) [Tip] Good posts to solve library sharing between multiple osx/ios projects.
11) [Tip] IOS weak link frame for multiple sdk compatibility
What you need to do is to build for iPhone OS 3.0, but in the build settings for your target set the iPhone OS Deployment Target to iPhone OS 2.0 (or whatever minimum version you'd like to support with your final application). This way, you weak-link against the newer framework, but can still deploy the application to older devices.
11) [UI] 让UIWebView支持Gesture
http://justinimhoff.com/swipe-gesture-with-uiwebview/
12) [UI, Tip] 在按钮上排列文字的图片的位置
Set the imageEdgeInset and titleEdgeInset to move the components around within your image.
http://stackoverflow.com/questions/2515998/iphone-uibutton-image-position/2516108#2516108
13) [UI Layout] 动态布局的一个很好的例子
Three20: TTStyledLayout.m
- (void)layoutText:(TTStyledTextNode*)textNode container:(TTStyledElement*)element {
以后陆续补充~
14) [UI TabBar] RaisedCenterTabBar
http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/
https://github.com/boctor/idev-recipes/tree/master/RaisedCenterTabBar
15) [Error] “wait_fences: failed to receive reply: 10004003”?
在viewDidAppear之前改变view上的元素
16) [Grammar] @synthesize and @dynamic
@synthesize will generate getter and setter methods for your property. @dynamic just tells the compiler that the getter and setter methods are implemented not by the class itself but somewhere else (like the superclass)
17) 尽量避免在viewDidLoad中使用alloc生成新的对象,如果有者需要在viewDidUnload中release;由于memory warning发生时候会触发viewDidUnload,因此viewDidLoad会被多次调用
---- 在viewDidLoad中alloc, 然后在viewDidUnload中release是比较正确的内存管理方式。针对这种情况需要在viewDidLoad中回复view的状态,所以也就需要使用一个数据模型记录view的状态。
IOS开发经验分享的更多相关文章
- iOS 6分享列表——UIActivityViewController详解
iOS 6分享列表——UIActivityViewController详解 2013-06-03 01:42:33 发表评论 在iOS 6之后提供了一个分享列表视图,它通过UIActivity ...
- iOS开发经验总结——基础工程
iOS开发经验总结--依赖库 这篇博客,我想说一下开发中经常遇到的一个问题,虚拟个场景描述一下的话,应该是这样的. 项目经理:今天我们正式开始一个新项目,iOSer你负责把苹果端的APP完成,有没有问 ...
- iOS 开发经验总结
iOS 开发经验总结http://www.cocoachina.com/ios/20170216/18699.html 1.cocoa pods 常用的framework 1 2 3 4 5 6 7 ...
- Nuxt开发经验分享
Nuxt开发经验分享 本文章基于starter-template模板进行讲解,面向有vue-cli开发经验的宝宝 vue init nuxt-community/starter-template ...
- vue history模式 ios微信分享坑
vue history模式 ios微信分享坑 问题分析:因为苹果分享会是调取签名失败是因为:苹果在微信中浏览器机制和安卓不同,有IOS缓存问题,和IOS对单页面的优化问题,通俗点说安卓进行页面跳转分享 ...
- ios微信分享的兼容性问题
我微信分享采用的是: 页面初始化时动态加载js-sdk, 然后在需要分享的页面进行sdk的分享初始化 app.vue store.vue 这种方法在安卓上完全正常, 好用得令人发指, 但是!!! io ...
- 钱包开发经验分享:ETH篇
# 钱包开发经验分享:ETH篇 [TOC] ## 开发前的准备 > 工欲善其事,必先利其器 一路开发过来,积累了一些钱包的开发利器和网站,与大家分享一下.这些东西在这行开发过的人都知道,只是给行 ...
- 【Meetup回顾】Apache DolphinScheduler在联通的实践和二次开发经验分享
在由 openLooKeng 社区主办,Apahce DolphinScheduler社区.Apache Pulsar 社区.示说网协办的联合 Meetup 上,来自联通数字科技的王兴杰老师分享了Do ...
- 百度地图 IOS版开发经验分享
最近刚完成app中地图的应用,感觉非常的曲折,折腾了很久,刚才开始一直不能成功使用百度地图api,报一大堆的错误,后来换到高德地图,又发现服务端使用的百度的经纬度,又从高德换回百度,泪奔. 这里简单比 ...
随机推荐
- jQuery选择器之表单对象属性过滤选择器Demo
测试代码: 08-表单对象属性过滤选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
- 洛谷P1251 餐巾(网络流)
P1251 餐巾 15通过 95提交 题目提供者该用户不存在 标签网络流贪心 难度提高+/省选- 提交该题 讨论 题解 记录 最新讨论 为什么我全部10个测试点都对… 题目描述 一个餐厅在相继的N天里 ...
- backbone.Collection源码笔记
Backbone.Collection backbone的Collection(集合),用来存储多个model,并且可以多这些model进行数组一样的操作,比如添加,修改,删除,排序,插入,根据索引取 ...
- EL表达式隐含对象
EL表达式语言中定义了11个隐含对象,使用这些隐含对象可以很方便地获取web开发中的一些常见对象,并读取这些对象的数据. 语法:${隐式对象名称} :获得对象的引用 <%@ page lang ...
- 增强for循环用法___ArrayList数组实现使用下标最好,LinkedList使用增强型的(转载)
总结: 1.For-Each循环的缺点:丢掉了索引信息. 当遍历集合或数组时,如果需要访问集合或数组的下标,那么最好使用旧式的方式来实现循环或遍历,而不要使用增强的for循环,因为它丢失了下标信息. ...
- 调用WCF接口的方法
通过对接口调用可能出现的异常作出判断和处理,避免资源的浪费和占用~ public class SvcHelper { public static void Using(T client, Action ...
- UML类图几种关系的总结[转]
原文地址:http://www.open-open.com/lib/view/open1328059700311.html 在UML类图中,常见的有以下几种关系: 泛化(Generalization) ...
- echarts标准饼图(一)——基本配置demo
echarts标准饼图解读共分为四部分, 一.基本配置demo 二.标题(title)配置 三.提示框(tooltip)配置 四.图例(legend)配置 五.系列列表(series )配置 下面是一 ...
- 远程连接postgres,出现server doesnt listen
已修改pg_hdb.conf中的 # IPv4 local connections: host all all 127.0.0.1/32 ...
- OpenGL 回顾——简化版的窗体(包含鼠标控制,普通键位控制,以及镜面反射)
// OpenGLBook.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" //变量声明 static GLfloat spin =0.0; ...