Tuesday, August 21, 2012

Useful Links and Sample code Links

 Default Splash Screen size

http://mobiledevelopertips.com/ipad/ipad-managing-multiple-launch-images.html

SOTC Link


json parsing

http://ganga.showontherun.com/JSONApi/GetAllAssetByCatId/?catid=1&userid=2&fields=catid,assets_id,filetype,thumb_url,normal_url,large_url,original_filename,version_number
web service


http://infowave.showonthecloud.com/index.php/application/phoneWeb/phoneweb/ws/1


Touch Json:










https://touchcode.googlecode.com/hg-history/falcon dev/README.txt //serialize and deserialize using touchJSON


Recording Audio

Recoding audio is done using AVAudioRecorder.

All the ipads are having in-build recording device( ie, Microphone). But some older version of IPod does not have microphone for recording. So it is better to check whether a device supports for recording.

Determining Whether a Device Supports Recording





Include AVFoundation framework.

BOOL inputAvailable;
inputAvailable = [[AVAudioSession sharedInstance] inputIsAvailable];

returns True, if microphone available.
False, does not have microphone.


Reference : http://developer.apple.com/library/ios/#DOCUMENTATION/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW57


Launching Your Application on Another Application via a Custom URL Scheme




To launch your app on another app, need to register a custom URL with iphone.

This is done via info.plist file located in ur app folder.

Step includes:
1. Open plist file - Right click and Add Row.
2. It shows a list. Choose URL Types, its having “Item 0”, expand Item 0 and provide URL identifier.
(Example URL Identifier: com.myapp).
3. Right click on Item 0 and Add Row, choose URL Scheme, again expand Item 0 which is below the URL Scheme and provide URL Scheme. (Example URL Scheme : myapp).





Include these delegate method given below in your AppDelegate.m file.

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
// Do something with the url here
}






- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
if (!url) { return NO; }

NSString *URLString = [url absoluteString];
[[NSUserDefaults standardUserDefaults] setObject:URLString forKey:@"url"];
[[NSUserDefaults standardUserDefaults] synchronize];
return YES;}


Its better to check the App, which is going to lauch inside your App is installed in the device using the code given below:

launchclass.m file:



NSURL *url=[NSURL URLWithString:@"myapp:\\"]; //Url Scheme
if([[UIApplication sharedApplication] canOpenURL:url])
{
// App installed. code to lauch
}
else
{
//App not Installed
}







ScrollView Touch :

In genral, there is no event for touch on scrollview. But it can be done in 2 ways :

Using
1. Custom ScrollView
2. UIGestureRecognizer

Custom ScrollView

1. Create a Subclass for the Class UIScrollView.
2. Include the Touch events (touchesBegin, touchesEnded, . . ) in subclass.m file.

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.nextResponder touchesBegan:touches withEvent:event];
}

3. Drag a ScrollView into ViewController.xib file, goto properties and assign subclass to the Class field.

We can make use of the Touchevents now.





Convert Image from Url


NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[appdelegate.Assert_Pic_Large objectAtIndex:[sender tag]]]];
imgLarge = [UIImage imageWithData:imageData];
img_selected.image=imgLarge;






21/12/12






















--






http://stackoverflow.com/questions/7531429/how-to-increase-height-of-cell-for-the-uiimagepickerviewcontroller //changing the default size of table cell from image picker(photo album)













27/12/11







https://code.google.com/apis/console // To get api key for google plus




27/Dec/11

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html

how to set alarm for music library //




03/03/12

Push OnTo NavigationController

Level1View *levelViewController=[[Level1View alloc]init];
//Set Animation Properties
[UIView beginAnimations:nil context:NULL];
// [UIView setAnimationDuration: 0.50];
[UIView setAnimationDuration: 4];

//Hook To MainView
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];


//Push OnTo NavigationController
[self.navigationController pushViewController:levelViewController animated:NO];
[levelViewController release];

//Start Animation
[UIView commitAnimations];





14/03/12

Background Active methods:

-(void)applicationWillEnterForeground:(UIApplication *)application
{

}

-(void)enterbackground
{

}



TextView (resignfirst responder)


-(BOOL)textViewUITextView *)tv shouldChangeTextInRangeNSRange)range replacementTextNSString *)text

{

if([text isEqualToString"\n"])

{

[textView resignFirstResponder];

return NO;

}

return YES;

}

//Communication

http://wabstalk.com/2011/04/how-to-make-questions-in-english/







FaceBook:
post text and captured image using camera:




Sqlite3 tutorial




http://www.iphonesdkarticles.com/2008/10/sqlite-tutorial-selecting-data.html // store and retrive and delete data from database

Basic
http://www.techotopia.com/index.php/An_Example_SQLite_based_iPhone_Application

twitter

pushnotification


GPS


Download and create an image



LinkedIn





My Map






Upload Image to Web Service:

source code:
http://zcentric.com/2008/08/29/post-a-uiimage-to-the-web/


pass required parameter to web server





post multiple images to web server

http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone






upload video to web server


http://stackoverflow.com/questions/5163587/uploading-image-or-a-video-to-server-as-a-raw-data-without-encoding
http://pastebin.com/qRkTsveh








Getting Current Time


NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *currentTime = [dateFormatter stringFromDate:today];
[dateFormatter release];



upload video from document directory to web server




Calendar




line break in lable or text view

textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;

refferd link





http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/instp/UIImagePickerController/mediaTypes

Urbanairship push notificatio

tutorial

https://docs.urbanairship.com/display/DOCS/Getting+Started%3A+iOS%3A+Subscriptions

sample code:


Rotate Wheel:



jsonp iPhone



four square





Socket







iOS - how to detect total available/free disk space on the iPhone/iPad device?



http://stackoverflow.com/questions/5712527/ios-how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device




Static library



SourceCode Sample App for IOS




Streaming and playing an MP3 stream




Streaming - how to get song name with AVAsset

http://stackoverflow.com/questions/9455805/streaming-how-to-get-song-name-with-avasset

Finding the device token




Basic Questions



Json Parsing Steps:


http://mobileorchard.com/tutorial-json-over-http-on-the-iphone/



Submitting iPhone Apps To The Apple App StoreA Step by Step Guide




iPhone Questions





Rich push Key value pair:(Reference link)






Swipe Handle..


UISwipeGestureRecognizer *recognizerleft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
[recognizerleft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[recognizerleft setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:recognizerleft];



- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
NSLog(@"leftSwipeHandle");
if (i<[imagearray count]-1) //CHECK FOR LAST PAGE
{
i++;
// appDelegate.imageType=0;
NSLog(@"intpage to display===>%d",i);
[imgView removeFromSuperview];
UIImage *img=[imagearray objectAtIndex:i];
imgView=[[UIImageView alloc]initWithImage:img];
imgView.frame=CGRectMake(0,0,img.size.width,img.size.height);
[self.view addSubview:imgView];
}
}



Device Detail




google plus



ios 5 customize navigation bar



Mailcomposer for ios 5


Facebook


//






Rate this App

UIActionSheet *popupQuery = [[UIActionSheet alloc]
initWithTitle:[NSString stringWithFormat:@"\n\n\nWe hope you're enjoying the Raaga App. Please leave a review on the App Store to encourage other users to download it."]
delegate:self
cancelButtonTitle:@"Not now"
destructiveButtonTitle:nil
otherButtonTitles:@"Rate the app",@"Don't ask again",nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;//UIActionSheetStyleBlackTranslucent
UILabel *pickerView = [[UILabel alloc] init];
pickerView.text = @"Love Raaga?";
pickerView.frame = CGRectMake(15,15,290,45);
pickerView.backgroundColor = [UIColor clearColor];
pickerView.font = [UIFont systemFontOfSize:18];
pickerView.textAlignment = UITextAlignmentCenter;
// pickerView.adjustsFontSizeToFitWidth = YES;
pickerView.textColor = [UIColor whiteColor];
pickerView.lineBreakMode = UILineBreakModeWordWrap;
pickerView.numberOfLines = 0;
// pickerView.datePickerMode = UIDatePickerModeDate;
[popupQuery addSubview:pickerView];
//[myUIActionSheet showInView:self.view];
[popupQuery setBounds:CGRectMake(0,0,320, popupQuery.bounds.size.height + pickerView.bounds.size.height)];
CGRect pickerRect = pickerView.bounds;
pickerRect.origin.y = - pickerView.bounds.size.height; //you may need to change this offset
pickerView.bounds = pickerRect;
[pickerView release];
// [popupQuery release];
// popupQuery.title.fastestEncoding
[popupQuery setTag:101];
[popupQuery showInView:self.tabBarController.view];
[popupQuery release];


//================
#pragma mark Action Sheet delegate methods..

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// NSLog(@"indix%d",buttonIndex);
if (actionSheet.tag==101)
{
if (buttonIndex == 0)
{//twitter
// NSLog(@"00000 rate this app");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RATEDSTATUS"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/addUserReview?id=421217877&type=Purple+Software"]];

}
else if (buttonIndex == 1)
{//Facebook
// NSLog(@"11111 dont ask again");
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RATEDSTATUS"];
}
else if(buttonIndex == 2)
{
// NSLog(@"22222 not now");
}
}
if (actionSheet.tag==2501)
{
if (buttonIndex == 0)
{
// if(!twt)
// twt=[[TwitterLogiView alloc]initWithNibName:@"TwitterLogiView" bundle:nil];
//[naviga pushViewController:twt animated:YES];
//[twt release]; } else if (buttonIndex == 1) {
}
else if(buttonIndex == 1) {
//Facebook sharing.
}

}
}




1.Multiple image upload to server using ELC imagepicker controller



pragma mark ELCImagePickerControllerDelegate Methods

- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info {
[self dismissModalViewControllerAnimated:YES];
for (UIView *v in [scrollview subviews]) {
[v removeFromSuperview];
}
CGRect workingFrame = scrollview.frame;
workingFrame.origin.x = 0;
for(NSDictionary *dict in info) {
UIImageView *imageview = [[UIImageView alloc] initWithImage:[dict objectForKey:UIImagePickerControllerOriginalImage]];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;
[scrollview addSubview:imageview];
[imagedelegate.imgarray addObject:imageview];
NSLog(@"array img====>%@",imagedelegate.imgarray);
[imageview release];
workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
}
[scrollview setPagingEnabled:YES];
[scrollview setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];
}


- (IBAction)uploadImage
{
loading.hidden=NO;
[loading startAnimating];
/*
turning the image into a NSData object
getting the image back out of the UIImageView
setting the quality to 90
*/
// setting up the URL to post to
//NSString *urlString = @"http://iphone.zcentric.com/test-upload.php";
//NSString *urlString=@"http://16sp3.showontherun.com/v2/uploadasset";
NSString *urlString=@"http://demoupload.showontherun.com/v2/uploadasset";
NSLog(@"upload clicked");
// NSString *urlString=@"http://showontherun.com/netfiles/fileupload.php";
/* for (int i=0; i<[imagedelegate.imgarray count]; i++)
{
UIImageView *img=[[UIImageView alloc] init];
img=[imagedelegate.imgarray objectAtIndex:i];
[self performSelectorInBackground:@selector(Parsing:img:) withObject:urlString withObject:img];
}
*/
[self performSelectorInBackground:@selector(Parsing:) withObject:urlString];
// setting up the request object now
}


- (void)Parsing:(NSString *)searchString
{
for (int i=0; i<[imagedelegate.imgarray count]; i++)
{
UIImageView *img=[[UIImageView alloc] init];
img=[imagedelegate.imgarray objectAtIndex:i];

NSString *Filename=@"rajesh";
NSString *UserId=@"rajesh@i-waves.com";
int assetid=0;
int versionnumber=1;
int privateasset=1;
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *currentTime = [dateFormatter stringFromDate:today];
[dateFormatter release];
NSString *uploadtype=@"Normal";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:searchString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
NSLog(@"content type====>%@",contentType);
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
//To pass the user_id parameter
NSMutableData *body = [NSMutableData data];
NSData *imageData = UIImageJPEGRepresentation(img.image,90);
NSLog(@"converted img");
//NSData *img=UIImagePickerControllerSourceTypePhotoLibrary(scrollview,90);
// NSData *imageData1 = UIImageJPEGRepresentation(image1.image, 90);
// NSData *imageData2 = UIImageJPEGRepresentation(image2.image, 90);
// NSData *imageData3 = UIImageJPEGRepresentation(image3.image, 90);
/*
now lets create the body of the post
*/
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; Filename=\"rajesh.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"uplod start+++");

[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"Filename\"\r\n\r\n%@",Filename] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"user_id\"\r\n\r\n%@",UserId] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"user_id\"\r\n\r\n%@",UserId] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//To pass the asset_id parameter
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"asset_id\"\r\n\r\n%d",assetid] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//To pass the version_num parameter
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"version_num\"\r\n\r\n%d",versionnumber] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//To pass the start_Time parameter
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"start_Time\"\r\n\r\n%@",currentTime] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//To pass the uploadtype parameter
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"uploadtype\"\r\n\r\n%@",uploadtype] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//To pass the privateasset parameter
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"privateasset\"\r\n\r\n%d",privateasset] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//close the form
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//////////////////////
//////////////
[request setHTTPBody:body];
// now lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(returnString);
/*NSRange range2=[returnString rangeOfString:@"success"];
if (range2.location!=NSNotFound)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"Upload Successfully." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
*/
[request release];
request=nil;
[loading stopAnimating];
loading.hidden=YES;
//ShowUploadImage.userInteractionEnabled=YES;
}
NSRange range2=[returnString rangeOfString:@"success"];
[imagedelegate.imgarray removeAllObjects];

if (range2.location!=NSNotFound)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"Upload Successfully." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}



Where does the iPhone Simulator store its data?



Instagram Image Filters on iPhonert






How to send and receive message through NSNotificationCenter in Objective-C?


Image processing techniques for iphone



Some example codes





iPhone Tutorial | iPhone iOS4 iPad SDK Development & Programming Blog


http://www.edumobile.org/iphone/iphone-programming-tutorials/submitting-iphone-apps-to-the-apple-app-store-a-step-by-step-guide/



inApp Reference


inApp Test Acc


SQLITE



Open GL