`
tonynju
  • 浏览: 74513 次
  • 性别: Icon_minigender_1
  • 来自: 浙江嘉善
社区版块
存档分类
最新评论

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 写道

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的状态。


 

Reference:

http://stackoverflow.com/

http://www.raywenderlich.com/

 

 

 

 

分享到:
评论

相关推荐

    UDK-iOS开发经验分享_虚幻开发者

    UDK iOS Unreal3 虚幻开发 讲解iOS开发中的各种坑 曾经遇到的问题   不能修改C++ 代码,也不支持DllBind   不支持Material材质树   不支持Morph Target   没有UI编辑器,不支持UI动画   不支持...

    iOS开发入门心得与实战经验分享.zip

    内容概要:这篇文章是一篇关于iOS开发的入门心得和实战经验分享。作者以通俗易懂的语言,介绍了iOS开发的基本概念,如UIKit、AutoLayout、Delegate等,并分享了自己在实际项目中使用iOS开发的经验和心得。 适用人群...

    iOS开发深度剖析:项目实战、经验分享与技术探索

    iOS开发深度剖析:项目实战、经验分享与技术探索 引言 iOS开发是一个充满挑战和创新的领域,本文将分享我在iOS开发的项目实战中所积累的经验,并提供相关的练习,希望能够为初学者提供有价值的参考。 项目实战...

    swift-学习和分享iOS开发的知识和经验

    该项目旨在学习和分享iOS开发的知识和经验,并尝试构建完整的堆栈开发系统

    IOS开发介绍PPT(详细PPT)

    同时,我们还分享了IOS开发的最佳实践和优化技巧,帮助开发者提升应用性能和用户体验。 此外,本PPT还关注IOS开发的最新动态和前沿技术。我们梳理了近年来IOS开发领域的新技术、新工具和新趋势,为观众提供了最新的...

    ios开发介绍&心得&项目&相关练习

    通过描述项目的需求分析、设计、编码实现和测试等环节,读者可以了解到iOS开发的完整过程,并学习到一些实用的开发经验和技巧。 最后,文章提供了一些与iOS开发相关的练习建议。这些练习涵盖了基础语法和控件、网络...

    CMDN CLUB#15期:讯飞语音云控件在iOS快速集成经验分享

    CMDN CLUB#15期:讯飞语音云控件在iOS快速集成经验分享

    iOS开发你需要知道的

    此资源是本人从事iOS开发以来,实际工作中遇到的问题及坑点的总结。皆在为后来者提供一种思路或解决方案, “授人以鱼,不如授人以渔”就是这个道理。 希望我的这些开发中的工作经验能真正的帮助到你, 此为本人分享...

    ios游戏实战开发(cocos2dcocos2d-xUnity3d)

    华仔老师的(ios游戏实战开发(cocos2dcocos2d-xUnity3d))这套教程,个人感觉感触良多,特别分享给大家。教程一共有180课时。以下是介绍! 课程简介 1、本系列课程分为基础篇、项目实战篇共:180学时,45-60分钟/课时...

    iOS DevCamp幻灯片分享:社区类iPhone应用开发的技术实践 | 麻麻帮 陈剑飞

    本演讲将结合讲师这些年自学iPhone开发的历程,结合自己多个应用开发实践的案例,与大家分享iOS开发的技术实践,内容将涉及:开源框架的选择,如何搭建程序架构从而写更干净的代码,如何有效使用内存和防止内存泄露...

    iOS应用逆向工程

    中高级iOS开发人员;架构师    全球首本讲解iOS8应用逆向工程的实战手册,作者毫无保留地分享了数年来在iOS逆向工程领域的经验;  内容系统深入,逻辑紧密,实战性强,从iOS系统架构等理论出发,以多个实例贯穿...

    储双双:讯飞语音云控件在iOS快速集成经验分享

    他的演讲围绕“讯飞语音云控件在iOS快速集成经验分享”主题,分别给大家介绍以下三个部分:一个是语音云控件介绍,给开发者带来的好处;第二个就是语音云控件的集成流程;最后与大家分享了个人集成一些常见的问题。

    iOS-Programming-Sharing:28岁,零基础,学习 iOS 编程经验分享

    零基础,学习 iOS 编程经验分享 28岁,零基础,我是这样学习 iOS 开发的 by:史江凯 简单介绍一下个人背景,西北某普通 985/211 大学本科毕业,电子商务专业,大学折腾过主机、玩过WordPress。 厌倦了石家庄某企事业...

    iOS开发之Xcode篇

    “iOS开发之Xcode”简单介绍了Xcode4.0以后版本的一些特性,同时选取了大家分享的开发教程和经验以及论坛里一些热门话题,希望能给新手一些建议。

    iOS开发进阶

    iOS开发进阶, 作者的经验分享, 设计到很多xcode的插件的使用方法, 带完整书签

    iOS DevCamp幻灯片分享:解开IPA文件的灰沙 -- 通过静态分析工具了解IPA实现 | 友盟 张超 (更新版)

    2009年在深圳第一次创业,主要从事iPhone应用的开发,完成了从技术到产品设计以及团队运营管理等全流程角色的转换,积累了丰富的iOS创业经验,熟稔App store的规则及流程,了解开发者的需求,并掌握了创业项目的全程...

    iOS-Share:ios开发qq群:460483960的资源共享中心

    网上的iOS开发资源层出不穷,但是质量也良莠不齐,很多知识点已经过时或者存在误导,而且开发者们更需要的是一个可以系统性的查阅和提高自身水平的平台,所谓自己动手,丰衣足食,我和一群志同道合的朋友们便建立了...

    移动开发经验及学习资料小程序开发级安卓工程师跳槽经验微信小程序开发实践等资料14个合集.zip

    移动开发经验及学习资料小程序开发级安卓工程师跳槽经验微信小程序开发实践等资料14个合集: iOS 上基于 RxSwift 的动态表单填写.pdf Python 开发者的微信小程序开发实践.pdf 使用 Mpvue 开发微信小程序的最佳实践....

    iOS DevCamp幻灯片分享:《Passbook实战详解》| 爱图腾 廉洁

    iOS DevCamp幻灯片分享:《Passbook实战详解》| 爱图腾 廉洁 话题简介:iOS6发布后最值得关注...讲师简介:廉洁,爱图腾科技的技术总监,有多年从事Java开发和Javascript前端开发的经验,是国内最早的一批iOS开发者。

    iOS应用逆向工程(第2版)

    全球第一本讲解iOS8应用逆向工程的实战手册,作者毫无保留地分享了数年来在iOS逆向工程领域的经验。 内容系统深入,逻辑紧密,实战性强,从iOS系统架构等理论出发,以多个实例贯穿全书,阐述class-dump、Theos、...

Global site tag (gtag.js) - Google Analytics