`
tonynju
  • 浏览: 75480 次
  • 性别: 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/

 

 

 

 

分享到:
评论

相关推荐

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

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

    iOS开发进阶-完整版

    #### 四、实战项目经验分享 - **App架构设计**: - MVC(Model-View-Controller)模式优缺点分析。 - MVVM(Model-View-ViewModel)架构模式实践。 - 单例模式、观察者模式等设计模式的应用场景。 - **单元测试...

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

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

    ios开发90个实例源码苹果ios系统项目开发学习资料

    在iOS开发领域,掌握核心技术和实践经验至关重要。"ios开发90个实例源码苹果ios系统项目开发学习资料"提供了一套丰富的学习资源,适合初学者和有经验的开发者提升技能。这个压缩包包含90个不同的iOS应用实例,涵盖了...

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

    在Swift学习和分享iOS开发的过程中,我们涉及到一系列关键知识点,这些知识构成了iOS应用程序开发的基础。首先,Swift语言是苹果公司推出的编程语言,专为iOS、iPadOS、macOS、watchOS和tvOS平台设计,它提供了简洁...

    《iOS开发进阶》 PDF电子书下载 带书签目录 完整版

    ### 三、实战项目经验分享 - **项目架构设计**:一个好的项目架构对于维护和扩展性至关重要。本书可能会讨论MVC、MVVM等多种设计模式的应用场景及优缺点分析。 - **网络通信技术**:随着移动互联网的发展,数据传输...

    ios开发经验和技巧

    在iOS开发中,经验与技巧的积累对于提升项目的质量和效率至关重要。本文将分享一些资深iOS开发者在实践中总结的关键知识点。 首先,我们来讨论内存管理。在iOS开发中,内存管理是优化应用性能的关键。特别是在涉及...

    传智播客iOS教程+iOS开发零基础入门教程(1.1)

    最后,iOS开发也包括对推送通知、多任务处理、动画效果、地图集成、社交媒体分享等功能的实现。通过不断学习和实践,初学者能够逐渐掌握iOS开发的全面技能,从而创造出自己的高质量应用。 总之,"传智播客iOS教程+...

    IOS开发工程师面试常见问题

    ### iOS开发工程师面试常见问题详解 #### 一、你为什么热衷于软件开发? 热衷于软件开发的原因可以从个人兴趣出发,例如对于解决问题的热情、对于创造性的追求等。此外,还可以从行业前景和个人职业发展角度进行...

    IOS开发介绍PPT(详细PPT)

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

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

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

    62个IOS开发资料集锦

    3. **PhoneClube第六期:高效手机程序开发经验分**: 这里可能包含了如何高效开发手机应用的经验分享,可能涉及性能优化、内存管理、应用设计等。 4. **Objective-C入门教程中文版**: Objective-C是iOS开发中传统的...

    iOS5 程序开发

    总的来说,《iOS5程序开发》这本书是iOS开发者的重要参考资料,无论你是初学者还是有经验的开发者,都能从中获得宝贵的指导,提升你的iOS应用开发技能。通过阅读和实践书中的内容,你将能够充分利用iOS5提供的各种新...

    ios开发技巧与规范

    Stack Overflow、Reddit等平台都是获取帮助和分享经验的好地方。 #### 结论 编写高质量的Objective-C代码不仅能够提高软件产品的稳定性和性能,还能增强团队成员之间的协作效率。通过遵循上述最佳实践和技巧,...

    高性能 iOS 应用开发

    本书适合已经具备Objective-C和iOS开发经验的读者。这些开发者通常已经掌握了iOS应用开发的基础知识,但他们还需要提升对性能优化方面的深入理解。通过阅读本书,他们可以学习到如何从底层优化代码,如何将性能优化...

    (李智维)单元测试与自动化.pdf

    ### 单元测试与自动化——李智维 iOS 开发经验分享 #### 一、作者背景介绍 李智维,一位年轻的技术人才,21岁时已积累了丰富的开发经验。他在中学时期就参加了算法竞赛,展现了其对编程技术的兴趣与天赋。大学期间...

    ios6开发进阶与实战源码

    《iOS6开发进阶与实战源码》是一个针对苹果iOS6平台深入学习和实践的资源集合,主要面向已经掌握基础iOS开发的开发者,旨在提升他们的技能并提供实战经验。这个资源包,名为"MoreiOS6Development-master",包含了...

Global site tag (gtag.js) - Google Analytics