一些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的当前方向:

  1. UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
  2. if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
  3. ... ...
  4. } else {
  5. ... ...
  6. }

5) [Memory Management] Release a variable and set it to nil is a good habit.

  1. // 在viewDidLoad中alloc或者new的对象空间需要在这边释放
  2. - (void)viewDidUnload {
  3. [_sushiTypes release];
  4. _sushiTypes = nil;
  5. }
  6. - (void)dealloc {
  7. [_sushiTypes release];
  8. _sushiTypes = nil;
  9. [super dealloc];
  10. }

http://www.raywenderlich.com/2657/memory-management-in-objective-c-tutorial 写道

Note that you also set the object to nil afterwards. This is a good practice, because by setting it to nil it avoids a lot of problems. Any time you call a method on a nil object, it does nothing, but if you don’t set it to nil, if you tried calling a method on a deallocated object your program should crash.

6) [Other] #import and @class declaration usage

http://stackoverflow.com/questions/322597/class-vs-import/1350029#1350029 写道
Three simple rules: * Only #import the super class in header files. * #import all classes you send messages to in implementation. * Forward declarations for everything else. If you do forward declaration in the implementation files, then you probably do something wrong.

7) [UIWebView] UIWebView 和 应用之间的交互

http://stackoverflow.com/questions/3738212/getting-objective-c-to-talk-to-javascript-with-uiwebview/3738235#3738235 写道
You can send data from the Cocoa layer to the JavaScript layer by using the stringByEvaluatingJavaScriptFromString: method in 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.

http://zetetic.net/blog/2010/02/15/building-static-libraries-to-share-code-on-iphone-and-mac-os-x-projects/

ios和osX之间可以重用的代码

使用c编写Android和IOS共享代码的可行性

11) [Tip] IOS weak link frame for multiple sdk compatibility

http://stackoverflow.com/questions/2627797/weak-link-framework/2629693#2629693 写道
You are getting that error because you are building against a version of the SDK that does not implemement the MessageUI framework.
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开发经验分享的更多相关文章

  1. iOS 6分享列表——UIActivityViewController详解

    iOS 6分享列表——UIActivityViewController详解 2013-06-03 01:42:33     发表评论 在iOS 6之后提供了一个分享列表视图,它通过UIActivity ...

  2. iOS开发经验总结——基础工程

    iOS开发经验总结--依赖库 这篇博客,我想说一下开发中经常遇到的一个问题,虚拟个场景描述一下的话,应该是这样的. 项目经理:今天我们正式开始一个新项目,iOSer你负责把苹果端的APP完成,有没有问 ...

  3. iOS 开发经验总结

    iOS 开发经验总结http://www.cocoachina.com/ios/20170216/18699.html 1.cocoa pods 常用的framework 1 2 3 4 5 6 7 ...

  4. Nuxt开发经验分享

    Nuxt开发经验分享 本文章基于starter-template模板进行讲解,面向有vue-cli开发经验的宝宝 vue init nuxt-community/starter-template   ...

  5. vue history模式 ios微信分享坑

    vue history模式 ios微信分享坑 问题分析:因为苹果分享会是调取签名失败是因为:苹果在微信中浏览器机制和安卓不同,有IOS缓存问题,和IOS对单页面的优化问题,通俗点说安卓进行页面跳转分享 ...

  6. ios微信分享的兼容性问题

    我微信分享采用的是: 页面初始化时动态加载js-sdk, 然后在需要分享的页面进行sdk的分享初始化 app.vue store.vue 这种方法在安卓上完全正常, 好用得令人发指, 但是!!! io ...

  7. 钱包开发经验分享:ETH篇

    # 钱包开发经验分享:ETH篇 [TOC] ## 开发前的准备 > 工欲善其事,必先利其器 一路开发过来,积累了一些钱包的开发利器和网站,与大家分享一下.这些东西在这行开发过的人都知道,只是给行 ...

  8. 【Meetup回顾】Apache DolphinScheduler在联通的实践和二次开发经验分享

    在由 openLooKeng 社区主办,Apahce DolphinScheduler社区.Apache Pulsar 社区.示说网协办的联合 Meetup 上,来自联通数字科技的王兴杰老师分享了Do ...

  9. 百度地图 IOS版开发经验分享

    最近刚完成app中地图的应用,感觉非常的曲折,折腾了很久,刚才开始一直不能成功使用百度地图api,报一大堆的错误,后来换到高德地图,又发现服务端使用的百度的经纬度,又从高德换回百度,泪奔. 这里简单比 ...

随机推荐

  1. 使用Jeditable插件时遇到的问题

    Jeditable在渲染页面已有DIV=>form的时候 首先使用 $("div").html(); 去获取原DIV中的内容. 这样导致一个问题, 如果原div中带有html ...

  2. 浅析为什么char类型的范围是 —128~+127

    转载于daiyutage 在C语言中, signed char 类型的范围为-128~127,每本教科书上也这么写,但是没有哪一本书上(包括老师)也不会给你为什么是-128~127,这个问题貌似看起来 ...

  3. asp.net的简单分页程序

    *.apsx页面 1: <%@ Page Language="C#" Debug ="true" AutoEventWireup="true&q ...

  4. ASP.NET发布WebService

    1. 创建一个空的Web应用程序 2. 再添加一个Web服务 3. 在所创建Web服务内,编写一算法 4. 写完可直接运行查看结果 5. 项目->右键,发布此WebService 6.  发布至 ...

  5. C#代码配置IIS 操纵IIS

    前言: IIS到目前经历了四个版本分别为 IIS4.0  IIS5.0 IIS6.0 IIS7.0,其中IIS6.0 IIS7.0是在5.0的安全问题的基础上获得的发展,目前为止.6.0版本以后的都是 ...

  6. UI3_UICollectionViewMuti

    // AppDelegate.m // UI3_UICollectionViewMuti // // Created by zhangxueming on 15/7/16. // Copyright ...

  7. web应用中webapp. root重用问题解决方案

      同一个tomcat服务器里面部署两个JavaEE项目,都是用了log4j做日志.并且web.xml里面都监听了日志信息. 启动服务的时候报错. 于是在web.xml添加以下代码:   <di ...

  8. 模板template

    1.模板就是实现代码重用机制的一种工具,它可以实现类型参数化,即把类型定义为参数,从而实现了真正的代码可重用性.模板可以分为两类,一个是函数模板,另一个是类模板. 2.函数模板的定义一般形式如下: t ...

  9. Regionals 2013 :: North America - Southeast USA

    Regionals 2013 :: North America - Southeast USA It Takes a Village As a Sociologist, you are studyin ...

  10. C++使用类型代替枚举量

    自己写的C++类型枚举量,可以使用类型识别取代模板,绑定枚举量和多组调用函数,在调用阶段只要指定某组函数就可以根据枚举量调用相应函数. 代码如下: #ifndef __MYENUM_H__ #defi ...