Thursday 28 April 2011

Change UISlider Image in Iphone


There are three images in UISlider you can change

1) left (default blue)
2) right (default white)
3) thumb (default white circle)


UIImage *sliderLeftTrackImage = [[UIImage imageNamed: @"SliderMin.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

UIImage *sliderRightTrackImage = [[UIImage imageNamed: @"SliderMax.png"] stretchableImageWithLeftCapWidth: 9 topCapHeight: 0];

1)
[mySlider setMinimumTrackImage: sliderLeftTrackImage forState: UIControlStateNormal];

2)
[mySlider setMaximumTrackImage: sliderRightTrackImage forState: UIControlStateNormal];

3)
[mySlider setThumbImage:[UIImage imageNamed:@"thumb_image.png"] forState:UIControlStateNormal];

Wednesday 27 April 2011

Use Google Analytics in iphone

Please see these links

1) http://code.google.com/mobile/analytics/docs/iphone/

2) http://www.icodeblog.com/2010/04/22/how-to-integrate-google-analytics-tracking-into-your-apps-in-7-minutes/

3) Sample code also available in this link
http://code.google.com/intl/fr/mobile/analytics/download.html#Google_Analytics_SDK_for_iOS

Sunday 24 April 2011

How to convert Seconds into minutes

for example

70 second = 1 minute and 10 second


double progress = ...... ;
int minutes = floor(progress/60);
int seconds = trunc(progress - minutes * 60);

Load Local html file using UIWebView

Ok here is the single line you need to load local html files :

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"01" ofType:@"html"]isDirectory:NO]]];


This line loads a html-file named '01.html' which has to be located in your project resources.

Saturday 23 April 2011

Reserved characters after percent-encoding

! %21
* %2A
' %27
( %28
) %29
; %3B
: %3A
@ %40
& %26
= %3D
+ %2B
$ %24
, %2C
/ %2F
? %3F
# %23
[ %5B
] %5D

Friday 22 April 2011

Split one string into different strings

NSString *str = @"011597464952,01521545545,454545474,454545444|Hello this is were the message is.";

NSArray *firstSplit = [str componentsSeparatedByString:@"|"];
NSAssert(firstSplit.count == 2, @"Oops! Parsed string had more than one |, no message or no numbers.");
NSString *msg = [firstSplit lastObject];
NSArray *numbers = [[firstSplit objectAtIndex:0] componentsSepratedByString:@","];

// print out the numbers (as strings)
for(NSString *currentNumberString in number) {
NSLog(@"Number: %@", currentNumberString);
}

Friday 15 April 2011

get Time from NSDate


NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString* currentTime = [dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];


UITextField: how to dismiss the Keyboard and Number Pad Keyboard

There are two ways, second is the easy way.


1) define delegate and

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}



2)


-(void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event
{
// do the following for all textfields in your current view
[self.txtfieldname resignFirstResponder];
// save the value of the textfield, ...
}

3) Dismiss textview    

Define Delegate

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
   
    if([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
   
    return YES;
}

Sunday 3 April 2011

Installing an Ad Hoc Distribution

What is Ad Hoc Distribution?

Ad Hoc Distribution allows you to try an application before it’s
available in the iTunes App Store. This is how we distribute iPhone
applications to beta customers.

These instructions assume you have a .zip file. You can also look at instructions for
.ipa files.

Developers, if you have any customers running Windows Vista, you’re better off distributing with an .ipa file, so that iTunes handles the unzipping. To create a .ipa, move your AppName.app directory into a new directory called Payload, then zip the Payload folder and change the file extension to .ipa.

What You’ll Need

Before beginning the installation process you’ll need:
  • The .zip file for the application
    (usually AppName.app.AdHoc.zip)
  • The .mobileprovision file for the application
    (usually Ad_Hoc_Distribution_Profile.mobileprovision)
  • Your Device: the iPhone or iPod Touch whose UDID you emailed us
    previously (Remember?)
  • The computer you normally sync with your Device
We usually send the .zip and .mobileprovision files to you via email.

Installing the Application - Windows XP


  1. If you have the .zip and .mobileprovision files in an email, save them to a convenient location, such as your Desktop.
  2. Drag-and-drop the .mobileprovision file onto LibraryApplications in iTunes. On the Mac,
    you can just drag it to the iTunes icon in your dock.
    Winxp-itunes-add-mobileprovision-profile
  3. Extract the .zip file. To do this, right-click the .zip file and select Extract All… . Step through the wizard and accept the defaults by clicking Next.

    WINDOWS VISTA USERS: The built-in “Extract All…” command
    corrupts the application so that it cannot be installed. You should
    try using a different zip program like WinZip or WinRar to extract the
    Zip file. Better yet, ask the application developer to send you the
    application as a .ipa file instead of a .zip file,
    then you don’t have to unzip it.
    Winxp-extract-all
  4. Find the .app folder (usually AppName.app).
    Winxp-app-folder
  5. Drag-and-drop the whole .app folder onto LibraryApplications in iTunes. On the Mac, you can just drag it onto the iTunes icon in the dock.
    Winxp-itunes-add-app
  6. Verify that the application shows up in LibraryApplications. Note that it will not have its normal icon.
    Winxp-itunes-library-applications
  7. In iTunes, select your Device under Devices, choose the Application tab, and make sure that the new application is checked.
    Winxp-itunes-devices-iphone-applications
  8. Sync your Device and try out the new app!

If you run into any trouble installing an app,

please email the application developer.


Friday 1 April 2011

Iphone project most common configuration problems


Please check your Configuration (Release / Debug) in Project Settings
It is damn shit that default is release mode …. but you compile in debug mode
or vice versa

means set your configuration (like Header search paths, other linker flag)
in both release and debug mode.