Seven useful iOS development sdks of Mo DeJong (1)

Source: Internet
Author: User

Translated from http://www.modejong.com/iOS/#ex7

In his blog, Mo DeJong provides seven interesting sample SDK programs (for xcode 3.2.5 and iOS 4.2). "These programs and prompts are specifically written for developers, however, the source code is open to the public in the "as-is" mode ". I will test these seven sdks. The author is lazy, but I will give the code snippets and, if necessary, the modified Code. My development environment is xcode 4.5 + IOS 5.1, hoping to bring these "Old Code" to life.

Directory:

(1) Multi-Level uitableview

(2) PNG Animation

(3) read and write the caf format using the extendedaudiofile API

(4) use coreaudio for PCM Mixing

(5) autopropertyrelease class (automatically released memory class)

(6) Improve the fade-out effect of coreaudio

(7) 7zip (lzma) SDK

This log will mention (1) (2) and the remaining sdks will be explained in the subsequent logs.

Example 1: Multi-Level uitableview

"Do you think it is a little difficult to use uitableview? I found that there is a convenient way to create a multi-level tableview ...... But this is only for text. You can see how the texttabledata class customizes A tableview. "-- this is the situation and solution encountered by the author.

Source code: texttableexample.zip (30kb)

Note that an error is reported when you compile and run the program directly. The problem is that xcode 4.5 does not support assigning values to the nsstring class. (The same should be true for other cocoa classes), so we need to make a conversion:

Old Version code

for (TextTableElement* ttElement in inElements) {label = ttElement.label;label += 0x1; // Avoid compiler warning}

New Code

for (TextTableElement* ttElement in inElements) {label = ttElement.label;        int intLabel = [label intValue];intLabel += 0x1; // Avoid compiler warning        label = [NSString stringWithFormat:@"%d",intLabel];}

In this way, the nsstring value can be automatically increased.

The code can run smoothly. However, according to the current "popular standards", it seems that such a design is basically unavailable. We recommend another type of "Multi-Level" tableview -- foldable tableview:

Http://blog.csdn.net/kmyhy/article/details/5979560

You can also look at a good tableview example in code4app:

Http://code4app.com/ios/TableView%E7%9A%84%E5%90%84%E7%A7%8D%E6%93%8D%E4%BD%9C/50bf05986803fa8e5c000001

This example is a mode used by many apps. It is very suitable for organizing tableview containing large amounts of data.

Example 2: PNG Animation

IPhone/IOS does not support playing GIF-format animations, so continuous playing of animations requires some "curve saving" methods, I think most people will use coreanimation to play images continuously. It seems that this MO DeJong is particularly interested in audio and video processing. He uses mpmovieplayercontroller in mediaplayer. framework. "When you use mpmovieplayercontroller, You should catch your hair like I do ......" The author believes that the functions provided by the official API "most of them need to be improved by themselves" to play audio and video, and cannot be used to "continuously play some PNG images. Mpmovieplayercontroller cannot be used, and coreanimation will occupy all the memory.
-- What should I do? Let's look at the author's example. Play 30 PNG images of 480x320 at 15 FPS, and I will not translate them if I don't know much about CPU performance and audio support.

 

Source code: pnganimatordemo.zip (165kb)

The code runs normally. According to the author's description, his method only loads the image when it is needed, instead of reading all frames and then occupying the memory. Let's take a look at coreanimation's "cache-based" image playing method:

imageView =[[ UIImageView alloc ] initWithFrame : CGRectMake (0, 100, 320, 320)];imageView . animationImages =images;[images release ];imageView . animationDuration =10;imageView . animationRepeatCount =100;[ imageView startAnimating ];

The basic idea is to have an nsmutablearray array images, load the images one by one into images, and then pass them to the imageview for continuous playback.

The method is to repeat the Code:

if ((frame >= animationNumFrames) || (frame < 0))return;NSData *data = [animationData objectAtIndex:frame];UIImage *img = [UIImage imageWithData:data];imageView.image = img;

It seems that there is no big difference between the two. The animationdata here also loads all frames in advance. The efficiency improvement mentioned by the author here is not obvious in the current development environment.

Analyze the two and continue tomorrow!

========================================================== ========

This article comes from:Http://blog.csdn.net/zh405123507

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.