iPhone – Handle the Application Termination When the Phone Rings

When iPhone rings, the running application will quit until the phone call ends. So in code level, how could we handle this situation.

I found a post by Norman McEntire and he talked about the application behavior when the phone rings. Here is what he found.
Continue reading iPhone – Handle the Application Termination When the Phone Rings

健吾 – 富士康的心安草

電子加工廠富士康發生12宗懷疑跳樓的自殺事件,有說有勢力組織要求國內不要再報道自殺事件,所有題材不得再評論。2010年6月2日香港報章報道,富士康又有28歲工程師疑過勞死。《人民日報》人民論壇同日發表「心安是福」為題的評論文章。內文大意如下:

國王看到後花園內的花花草草都因為不及別人而枯萎,只剩一棵心安草仍然健在,國王問:「別的植物都枯萎了,為什麼你卻生長得這般勇敢樂觀,毫不沮喪呢?」心安草回答:「那是因為我不自卑,一點都不灰心失望,也沒有什麼非分之想,我只想好好做棵心安草。」

不知道這心安草,可不可以做出泥馬來。
Continue reading 健吾 – 富士康的心安草

iPhone – Delete Files in the Documents Directory of your iPhone Application

I am working for my next iPhone application which will create an audio file and save it in the Documents directory. I also created a table view which listed all the audio files such that user can delete them. Please note that the Documents directory is the only place where you can store your application files.
Continue reading iPhone – Delete Files in the Documents Directory of your iPhone Application

iPhone – Adding Image to UIBarButtonItem

Update @ 2012-08-02: If you are using XCode 4.3 or above. You could following the instruction provided by S.Littlehales.

I found that if u set an image to the UIBarButtomItem directly, only the shape of the image is shown in the view without any color. If you want to add an button image to UIBarButtonItem, you have to create a UIButton and set it to the view of the UIBarButtonItem.
Continue reading iPhone – Adding Image to UIBarButtonItem

iPhone – Add an UISlider For AVAudioPlayer

We can use AVAudioPlayer to play music. Now i want to add an UISlider as the music progress bar and user can fast skip the music.

Now i have a play button in the view and when user click it, i will play the music file as well as the following method.

  • playButtonClickedRun when the play button is clicked
  • updateSliderRun in 1 second interval to update the UISlider
  • sliderChangeFast skip the music when user scroll the UISlider

Continue reading iPhone – Add an UISlider For AVAudioPlayer

iPhone – Stop the Scheduled NSTimer

Yesterday we talk about how to make use of the NSTimer for scheduling a task.
iPhone – NSTimer Example
 

Sometimes, you may want to stop the scheduled task. Then you can use the invalidate method. If you invalidate a unfired NSTimer, that’s fine. But if you invalidate a fired NSTimer, the application will crashed. So how to by pass the problem?
Continue reading iPhone – Stop the Scheduled NSTimer

Dream BIG and go for it =)