Friday, December 30, 2011

iPad Launch Image Orientations


iPad Launch Image Orientations
To deal with various orientation options, a new naming convention has been created for iPad launch images. The screen size of the iPad is 768×1024, notice in the dimensions that follow the height takes into account a 20 pixel status bar.
Filename Dimensions
Default-Portrait.png * 768w x 1004h
Default-PortraitUpsideDown.png 768w x 1004h
Default-Landscape.png ** 1024w x 748h
Default-LandscapeLeft.png 1024w x 748h
Default-LandscapeRight.png 1024w x 748h
Default.png Not recommended
  • If you have not specified a Default-PortraitUpsideDown.png file, this file will take precedence.
** If you have not specified a Default-LandscapeLet.png or Default-LandscapeRight.png image file, this file will take precedence.

Tuesday, August 23, 2011

Divide value in three string


double distRemain = distInMeter;
originalDistRemain = distInMeter;
if(distRemain >0 && distRemain <10){
lblDistance.text = @"0";
lblDistance1.text = @"0";
int lastdigit = distRemain/1;
lblDistance2.text = [NSString stringWithFormat:@"%d",lastdigit];
 
}
else if(distRemain >=10 && distRemain < 100){
lblDistance.text = @"0";
int lasttwo = distRemain/10;
lblDistance1.text = [NSString stringWithFormat:@"%d",lasttwo];
distRemain = distRemain -(lasttwo *10);
int lastdigit = distRemain/1;
lblDistance2.text = [NSString stringWithFormat:@"%d",lastdigit];
}
else if(distRemain >=100 && distRemain < 1000){
int firstDigit = distRemain/100;
lblDistance.text = [NSString stringWithFormat:@"%d",firstDigit];
distRemain = distRemain - (firstDigit *100);
int lasttwo = distRemain/10;
lblDistance1.text = [NSString stringWithFormat:@"%d",lasttwo];
distRemain = distRemain -(lasttwo *10);
int lastdigit = distRemain/1;
lblDistance2.text = [NSString stringWithFormat:@"%d",lastdigit];
}

Monday, July 18, 2011

Void Pinter Meaning

Void Pinter Meaning :
void * p; 
The name of the blog comes from the world of software development. In the C, C++, and C# programming languages (and perhaps others), a void pointer is a variable containing an address in memory. The above line of code declares a void pointer named "p" that has not yet been set to an address. What is stored at the address is left unspecified and usually the void pointer is converted to be a pointer to a specific type (cast) before it is used. This construct gives the developer quite a bit of power, but as Uncle Ben said, "with great power, comes great responsibility". The developer can very easily shoot themselves in the foot with a void pointer, but when used carefully and in the right circumstances, one can accomplish wonderful things.

Thursday, July 7, 2011

PDF File attached in Email Composer in iPhone .

This piece of code also shows you how to attach pdfs as well.



UIButton *emailPdfButton=[[UIButton alloc]initWithFrame:CGRectMake(101010040)];
[emailPdfButton setBackgroundColor:[UIColor greenColor]];
[emailPdfButton addTarget:self action:@selector(emailPdf:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:emailPdfButton];



-(IBAction)emailPdf:(id)sender{
    
    //find if email exists
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {        
        //find atleast one email account is set up
        if([MFMailComposeViewController canSendMail])
        {
            MFMailComposeViewController *controller = [[MFMailComposeViewController allocinit];
[controller setMessageBody:nil isHTML:YES];
[controller setSubject:@"Subject."];
[controller setMessageBody:@"Body Of Email." isHTML:NO];
[controller setToRecipients:[NSArray arrayWithObjects:nil,nil]];
[controller addAttachmentData:[NSData dataWithContentsOfFile:[self GetPdfFilePath]]mimeType:@"application/pdf" fileName:@"file.pdf"];
controller.navigationBar.tintColor = [UIColor grayColor];
[controller setMailComposeDelegate:self];
[self presentModalViewController:controller animated:YES];
[controller release];
        
        }
        else
        {
            //display the alert that set up an email account
            UIAlertView *alertView = [[UIAlertView allocinitWithTitle:@"Error" message:@"Please set up your email account on device." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
            [alertView release];
        }
    }
    else
    {
        //display the alert that email account not available
        UIAlertView *alertView = [[UIAlertView allocinitWithTitle:@"Error" message:@"No valid email account available on device." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    
    }
    
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
    
    
    
    NSString *message = @"";
    switch (result) {
         
        case MFMailComposeResultCancelled:
            message = @"Email Canceled";
            break;
        case MFMailComposeResultSaved:
            message = @"Email Saved";
            break;
        case MFMailComposeResultSent:
            message = @"Email Sent";
            break;
        case MFMailComposeResultFailed:
            message = @"Email Failed";
            break;
        default:
            message = @"Email Not Sent";
            break;

            
    }
    UIAlertView *alertView = [[UIAlertView allocinitWithTitle:nil message:message delegate:nilcancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
    [controller dismissModalViewControllerAnimated:YES];
}

Special Thanks for Mobile and Social NEtwork Technology.
Dinesh Sharma

Tuesday, July 5, 2011

iPhone iPad : check the current device and set the nib manually.

ActiveJobDetail *objActiveDetail;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200    
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
objActiveDetail = [[ActiveJobDetail alloc]initWithNibName:@"ActiveJobDetail-iPad" bundle:nil];
}
else 
#endif
{
objActiveDetail = [[ActiveJobDetail alloc]initWithNibName:@"ActiveJobDetail" bundle:nil];
}


//ActiveJobDetail *objActiveDetail = [[ActiveJobDetail alloc]initWithNibName:@"ActiveJobDetail" bundle:nil];
[self.navigationController pushViewController:objActiveDetail animated:YES];
[objActiveDetail release];

Wednesday, May 11, 2011

E-mail Validation in javascript










Email:






Monday, May 9, 2011

Check and Get the focus on the input box through JavaScript on the UIWebView in iPhone.




  Document.body.focus();
  var  inID = document.activeElement.id;
   function Function1Delay()
      {
         if(document.activeElement .id  !=  inID)
          {
             inID = document.activeElement.id;
             alert('Start Scan');
             document.getElementById(inID).value='Dinesh Sharma';
             setTimeout("Func1Dealy()",200); 
          }
         else
          {
            setTimeout("Func1Delay()",500); 
          }
      }


1.

NSString *str12 = [NSString stringWithFormat:@"document.body.focus(); var inii=document.activeElement.id; function Func1Delay() {if(document.activeElement.id != inii){inii=document.activeElement.id; alert('start scan');document.getElementById(inii).value='dinesh sharma';setTimeout(\"Func1Delay()\", 500);} else { setTimeout(\"Func1Delay()\", 500);}}"];
[myWeb stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@" %@ Func1Delay(); ",str12]];


2.

/*
NSString *str1 = [NSString stringWithFormat:@"function showAlert() { alert('%@');}",str];
[myWeb stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"%@ showAlert(); ",str1]];
    */
3.[myWeb stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"var field = document.forms[0].q;" "field.value='something';"]];
//[myWeb stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"var field = document.activeElement; field.value='Dinesh Sharma';"]];

Friday, April 29, 2011

Get the Property form address contact in iPhone




strFirstName = (NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);

//Get mobile phone number
ABMultiValueRef phones =(NSString*)ABRecordCopyValue(person, kABPersonPhoneProperty);
mobile=@"";
NSString* mobileLabel;
for(CFIndex i = 0; i < ABMultiValueGetCount(phones); i++) {
mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
NSLog(@"",mobileLabel);
if([mobileLabel isEqualToString:@"_$!!$_"]) {
mobile = (NSString*)ABMultiValueCopyValueAtIndex(phones, i);
}
}
//get the email
//Get mobile phone number
ABMultiValueRef emailAddress =(NSString*)ABRecordCopyValue(person, kABPersonEmailProperty);
email=@"";
NSString* emailLabel;
for(CFIndex i = 0; i < ABMultiValueGetCount(emailAddress); i++) {
emailLabel = (NSString*)ABMultiValueCopyLabelAtIndex(emailAddress, i);
NSLog(@"",emailLabel);

if([emailLabel isEqualToString:@"_$!!$_"]) {
email = (NSString*)ABMultiValueCopyValueAtIndex(emailAddress, i);
}
}


- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker 
  shouldContinueAfterSelectingPerson:(ABRecordRef)person { 
customer.firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
customer.lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
customer.companyName = (NSString *)ABRecordCopyValue(person, kABPersonOrganizationProperty);
if (!customer.firstName.length) {
customer.firstName = @"*";
}
if (!customer.lastName.length) {
customer.lastName = @"*";
}
if (!customer.companyName.length) {
customer.companyName = @"";
}


CFStringRef email, emailLabel, phone, phoneLabel;
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSMutableDictionary *myPhoneDict = [NSMutableDictionary dictionaryWithCapacity:ABMultiValueGetCount(phoneMulti)];
for (CFIndex i = 0; i < ABMultiValueGetCount(phoneMulti); i++) { 
phoneLabel = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(phoneMulti, i));
phone = ABMultiValueCopyValueAtIndex(phoneMulti, i); 
[myPhoneDict setObject:(NSString*)phone forKey:(NSString*)phoneLabel];
CFRelease(phone);
CFRelease(phoneLabel);
if ( [myPhoneDict objectForKey:@"mobile"] != nil) {
customer.phone  = [myPhoneDict objectForKey:@"mobile"];
} else if ( [myPhoneDict objectForKey:@"home"] != nil) {
customer.phone  = [myPhoneDict objectForKey:@"home"];
} else if ( [myPhoneDict objectForKey:@"work"] != nil) {
customer.phone  = [myPhoneDict objectForKey:@"work"];
}

ABMutableMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
NSMutableDictionary *myEmailDict = [NSMutableDictionary dictionaryWithCapacity:ABMultiValueGetCount(multi)];
for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) { 
emailLabel = ABAddressBookCopyLocalizedLabel(ABMultiValueCopyLabelAtIndex(multi, i));
email = ABMultiValueCopyValueAtIndex(multi, i); 
[myEmailDict setObject:(NSString*)email forKey:(NSString*)emailLabel];
CFRelease(email);
CFRelease(emailLabel);
if ([myEmailDict objectForKey:@"home"] != nil) {
customer.email = [myEmailDict objectForKey:@"home"];
} else if ([myEmailDict objectForKey:@"work"] != nil) {
customer.email = [myEmailDict objectForKey:@"work"];
} else if ([myEmailDict objectForKey:@"other"] != nil) {
customer.email = [myEmailDict objectForKey:@"other"];
}
// get the address stuff
ABMultiValueRef streets = ABRecordCopyValue(person, kABPersonAddressProperty);
NSMutableDictionary *myAddressDict = [NSMutableDictionary dictionaryWithCapacity:ABMultiValueGetCount(streets)];
for (CFIndex j = 0; j < ABMultiValueGetCount(streets); j++) {
NSMutableDictionary *myLabelDict = [[NSMutableDictionary alloc] init];
CFDictionaryRef dict = ABMultiValueCopyValueAtIndex(streets, j);
CFStringRef typeTmp = ABMultiValueCopyLabelAtIndex(streets, j);
CFStringRef type = ABAddressBookCopyLocalizedLabel(typeTmp);
NSString *street = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressStreetKey) copy];
NSString *city = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressCityKey) copy];
NSString *state = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressStateKey) copy];
NSString *zip = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressZIPKey) copy];
NSString *country = [(NSString *)CFDictionaryGetValue(dict, kABPersonAddressCountryKey) copy];
if ((street != nil) && (street.length > 0))
[myLabelDict setObject:street forKey:@"street"];
if ((city != nil) && (city.length > 0))
[myLabelDict setObject:city forKey:@"city"];
if ((state != nil) && (state.length > 0))
[myLabelDict setObject:state forKey:@"state"];
if ((zip != nil) && (zip.length > 0))
[myLabelDict setObject:zip forKey:@"zip"];
if ((country != nil) && (country.length > 0))
[myLabelDict setObject:country forKey:@"country"];
[myAddressDict setObject:myLabelDict forKey:(NSString *)type];
[myLabelDict release];
[street release];
[city release];
[state release];
[zip release];
[country release];
CFRelease(dict);
CFRelease(type);
CFRelease(typeTmp);
}

NSString *theKey;
if ([myAddressDict objectForKey:@"home"] != nil) {
theKey = @"home";
} else if ([myAddressDict objectForKey:@"work"] != nil) {
theKey = @"work";
} else if ([myAddressDict objectForKey:@"other"] != nil) {
theKey = @"other";
}
if ([[[myAddressDict objectForKey:theKey] objectForKey:@"street"] length] > 0) {
customer.street = [[myAddressDict objectForKey:theKey] objectForKey:@"street"];
} else {
customer.street = @"";
}
if ([[[myAddressDict objectForKey:theKey] objectForKey:@"city"] length] > 0) {
customer.city = [[myAddressDict objectForKey:theKey] objectForKey:@"city"];
} else {
customer.city = @"";
}
if ([[[myAddressDict objectForKey:theKey] objectForKey:@"state"] length] > 0) {
customer.state = [[myAddressDict objectForKey:theKey] objectForKey:@"state"];
} else {
customer.state = @"";
}
if ([[[myAddressDict objectForKey:theKey] objectForKey:@"zip"] length] > 0) {
customer.postalCode = [[myAddressDict objectForKey:theKey] objectForKey:@"zip"];
} else {
customer.postalCode = @"";
}
if ([[[myAddressDict objectForKey:theKey] objectForKey:@"country"] length] > 0) {
customer.country = [[myAddressDict objectForKey:theKey] objectForKey:@"country"];
} else {
customer.country = @"";
}
CFRelease(streets);
CFRelease(phoneMulti);
CFRelease(multi);
[customer dehydrate];
[self dismissModalViewControllerAnimated:YES];
return NO; 
}

Wednesday, January 12, 2011

iPhone MapKit Framework to cache Google map for offline: Good Idea

1) Can MapKit Framework support caching Google Map on iPhone locally ? 
2) Can MapKit Framework support to use offline map during GPS-ing ?


Answer :
Unfortunately no, you cannot cache the google tiles (at least not in iOS 4.x). However, you can use an MKOverlay to create an overlay that displays and caches tiles from another map source like OpenStreetMap. Apple published an example TileMap overlay with their 2010 WWDC videos.


Reference link:
http://stackoverflow.com/questions/3792532/iphone-mapkit-framework-to-cache-google-map-for-offline-use


Q. I am working on GPS Track...but when my device is offline then not show the Map. Can you please help for shut out it ? or How to implement the tiles in my application ?
Answer preferred by Apple forum.
Answer 1. : As I understand it MapKit terms and conditions require Google, try route-me for an alternative framwork.


Answer 2. : MapKit maintains a fixed-size map tile cache that contains (roughly speaking) tiles for the most recently viewed areas.  If the device is offline, and your MKMapView is zoomed to an area for which there are no tiles in the tile cache, maps will not be available.

The only solution to this would be to bundle your own map tiles with your app and implement your own map view.  It's up to you to decide if that is worthwhile for your use case.

Thursday, January 6, 2011

Time difference between two different times.

NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
[dateFormatter setDateFormat:@"hh:mm:ss"];
NSDate* firstDate = [dateFormatter dateFromString:starttime];
NSDate* secondDate = [dateFormatter dateFromString:endtime];
NSTimeInterval ti = [secondDate timeIntervalSinceDate:firstDate];
//NSString *str1 = [NSString stringWithFormat:@"%d",ti];
//NSLog(@"str1 %@",str1);
NSUInteger h, m, s;
h = (ti / 3600);
m = ((NSUInteger)(ti / 60)) % 60;
s = ((NSUInteger) ti) % 60;
NSString *str = [NSString stringWithFormat:@"%d:%02d:%02d", h, m, s];
//NSLog(@" strdiff : %@ ",str);