Category Archives: iPhone

iPhone – Configuring the AVAudioSession and Output Audio to iPhone Speaker

I am working on the AVAudioRecorder and AVAudioPlayer. By default, the output audio is routed to the receiver instead of the iPhone speaker. In order to fulfill my requirement, i have to configure the AVAudioSession in the AppDelegate.

There are 2 ways to route the audio output to speaker.

  • Overriding the output audio route
  • Changing the default output audio route (iPhone OS 3.1 or above)

Continue reading iPhone – Configuring the AVAudioSession and Output Audio to iPhone Speaker

iPhone – Aligning UIToolbar Items on Code Level

In Xcode, If you want to add items to the UIToolbar, you need to create an NSArray which stores all the items and put them to the UIToolbar using the setItems method.

If you want to align one items on the left and the another one on the right. you need to create a space item in between the two button in the array. That’s just like adding a Flexible Space Bar Button Item in Interface Builder.
Continue reading iPhone – Aligning UIToolbar Items on Code Level

iPhone – UIScrollView with Paging Example

I have downloaded the PageControl example from developer.apple.com but i don’t know the reason why i cannot open the .xib in Interface Builder. Anyway, i cannot make use of this example for my purpose as i don’t how to remove the UIPageControl without using the Interface Builder.

So i follow the example to create a simple UIScrollView with paging feature by scrolling the screen in horizontal direction.

GitHub:ScrollViewWithPaging – Xcode project Continue reading iPhone – UIScrollView with Paging Example

iPhone – Add the Return Key for UIKeyboardTypeNumberPad

Update @ 2012-11-10: This solution in this post is outdated. please refer to the comment made by Jonny for the solution in iOS 6.

When you try to use the UIKeyboardTypeNumberPad for a UITextField, you will release that there is no return key and so the UIKeyboardTypeNumberPad cannot be dismissed.

Luckily, i find out a very good article which talk about the solution of the missing return key. It makes use of the NSNotification and NSNotificationCenter such that a DONE button image will pasted on the bottom left of the UIKeyboardTypeNumberPad. Here is the code for returning from the number pad after editing a UITextField.

*Update on 2010-09-11: The approach does not work in iOS SDK >= 4.0. if your are using 4.0, you can take a look at iPhone – Add the Return Key for UIKeyboardTypeNumberPad in iPhone SDK 4.

Continue reading iPhone – Add the Return Key for UIKeyboardTypeNumberPad

iPhone – Disable the Cut/Copy/Paste Menu on UITextField

Update @ 2012-07-11: for ios >= 5.1 canPerformAction:(SEL)action withSender:(id)sender is not working anymore. Please refer to the following post for more information
StackOverflow – How do you REALLY remove Copy from UIMenuController

 

If you want to disable the Cut/Copy/Paste Menu, add the following piece of code in the implementation file of the view controller which containing the UITextField
Continue reading iPhone – Disable the Cut/Copy/Paste Menu on UITextField