Posts

Adding an UITextField to an UIAlertView in iPhone / iOS application

As we all know, UIAlertView is subclassed from UIView, its possible to add sub views to the alert view. Today, we will try to add an text field to UIAlertView. The code is attached below.     UIAlertView *alert = [[ UIAlertView alloc ] initWithTitle : @"See the text field below"     message : @"this gets covered!\n"   delegate : self cancelButtonTitle : @"Dismiss" otherButtonTitles : @"OK" , nil ];      alert. tag  = 1 000 ;            UITextField *_textField = [[ UITextField alloc ] initWithFrame : CGRectMake ( 12 , 45 , 260 , 25 )];     [_textField  setPlaceholder : @"Place holder text" ];     _textField. tag = 1 00 ;     _textField. clearButtonMode = UITextFieldViewModeWhileEditing ;     [_textField  setBackgroundColor :[ UIColor whiteColor ]];     [_textField  becomeFirstResponder ];     [alert a...

Integrating ZXing QR Code reader in iPhone / iOS applications

I spent a lot of time in integrating the QR code reader in iOS applications. I like to share you the steps and let you know the basic bugs that may happen during the integration process and how to debug that too :) Step 1  Download the latest code for QR code reader, zxing framework from github here . Step 2  Drag and drop the ZXingWidget.xcodeproj file to your project. Step 3  Copy the cpp folder from downloaded files (zxing-2.0) to your project. (The download files (zxing-2.0) depends upon the version that has been downloaded from github.) Step 4  Copy the iphone folder from downloaded files (zxing-2.0) to your project. (The download files (zxing-2.0) depends upon the version that has been downloaded from github.) Step 5 Add the following frameworks to your project.  Click on Project name -> Target -> Build Phases -> Link with libraries AudioToolbox.framework AddressBookUI.framework AddressBook.framework CoreVideo.framewor...

Transparent UIWebView in iPhone application

Hi Folks, Today, lets try to implement a transparent web view in our iphone application. Its quite simple and easy to use. 1. Set the background color of UIWebView to clear color. [myWebView setBackgroundColor:[UIColor clearColor]]; 2. Set the Opaque property of the UIWebView to NO.  myWebView.opaque = NO; 3.  Set the html page, body background property in style to transparent.  You can refer the above mentioned settings given in Apple Sample code, TransWeb .

Transparent UIWebView in iPhone application

Hi Folks, Today, lets try to implement a transparent web view in our iphone application. Its quite simple and easy to use. 1. Set the background color of UIWebView to clear color. [myWebView setBackgroundColor:[UIColor clearColor]]; 2. Set the Opaque property of the UIWebView to NO.  myWebView.opaque = NO; 3.  Set the html page, body background property in style to transparent.  You can refer the above mentioned settings given in Apple Sample code, TransWeb .

Add a custom keyboard shortcut key in Mac OS

To add a custom short cut key in Mac OS, follow the below steps. 1. Open System Preference. 2. Select Keyboard. It will load the preferences for Keyboard. 3. Click on Keyboard Shortcuts. 4. Select Application Shortcuts on the left panel. It will load a list of shortcuts on the right panel. 5. To add a new shortcut, click on the '+' button placed at the bottom of the right panel. It will open a dialog with the options. 6. Fill up the dialog as you required and click on 'Add'. 7. Your new custom keyboard shortcut is ready to use now. To find out the list of available shortcut keys in Mac OS, check out this link from Apple .

Cropping a part of UIImage in iPhone

To crop any part of an image in iPhone using Objective C, start with an UIImage object.    UIImage *image; Create a bitmap representation the image using the CGImageRef class.    CGImageRef imageReference = image.CGImage; Define the frame size for the part of image which should be cropped.    CGRect cropFrame = CGRectMake(10, 10, 50, 50); Now set the current context of UIGraphics    CGContextRef context = UIGraphicsGetCurrentContext(); Draw the image using the crop frame and imageReference using the current context.    CGContextDrawImage(UIGraphicsGetCurrentContext(), cropFrame, imageReference); Save the cropped image on a new UIImage object.    UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext(); After consolidating the above code to a single shot, it looks like,    UIImage *image;    CGImageRef imageReference = image.CGImage;  ...

Multiple line of text in UIPickerView

UIPickerView is a user interface component available from iOS 2.0 and above. The basic need of UIPickerView is to select any one option from the list of data that are loaded to the picker view. But, by default, only one line of text is allowed to be displayed in a UIPickerView . Today, we will try to add multi-line text to an UIPickerView . To do so, we need to implement the viewForComponent api.   - ( UIView  *)pickerView:( UIPickerView  *)pickerView viewForRow:( NSInteger )row forComponent:( NSInteger )component reusingView:( UIView  *)view; In that method, type cast the view parameter to an UILabel.    UILabel *pickerLabel = ( UILabel *)view; Update the frame size of the label.    CGRect frame = CGRectMake ( 0 , 0 , 265 , 40 );    pickerLabel = [[[ UILabel alloc ] initWithFrame :frame] autorelease ]; Set the properties of the label as per requirement.    [pickerLabel setTextAlig...