Loading

Monday, August 22, 2011

Open Doc Files from Another Application

1. in AppDelegate
if (launchOptions && [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey])
{

printf("Launch options:\n");
CFShow(launchOptions);
NSString *filePath = [NSString stringWithFormat:@"%@", (NSURL*)[launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSMutableArray *ArrTmp;
if ([[prefs objectForKey:@"DocArray"] count])
{
ArrTmp=[[prefs objectForKey:@"DocArray"] mutableCopy];
}
else
{
ArrTmp=[[NSMutableArray alloc] init];
}
[ArrTmp addObject:filePath];
[prefs setObject:ArrTmp forKey:@"DocArray"];

}


2. Add These Value in infoPList


CFBundleDocumentTypes


CFBundleTypeIconFile
Icon.png
CFBundleTypeName
PDF
CFBundleTypeRole
Editor
LSItemContentTypes

com.adobe.pdf

LSTypeIsPackage

NSDocumentClass
Document
NSPersistentStoreTypeKey
Binary


CFBundleTypeIconFile
Icon.png
CFBundleTypeName
BMP
CFBundleTypeRole
Editor
LSItemContentTypes

com.microsoft.bmp

LSTypeIsPackage

NSDocumentClass
Document
NSPersistentStoreTypeKey
Binary


CFBundleTypeIconFile
Icon.png
CFBundleTypeName
W8BN
CFBundleTypeRole
Editor
LSItemContentTypes

com.microsoft.word.doc

LSTypeIsPackage

NSDocumentClass
Document
NSPersistentStoreTypeKey
Binary


CFBundleTypeIconFile
Icon.png
CFBundleTypeName
XLS8
CFBundleTypeRole
Editor
LSItemContentTypes

com.microsoft.excel.xls

LSTypeIsPackage

NSDocumentClass
Document
NSPersistentStoreTypeKey
Binary


CFBundleTypeIconFile
Icon.png
CFBundleTypeName
SLD8
CFBundleTypeRole
Editor
LSItemContentTypes

com.microsoft.powerpoint.​ppt

LSTypeIsPackage

NSDocumentClass
Document
NSPersistentStoreTypeKey
Binary




Now it handle PDF,Doc,Xls,Ppt files and you have all open files in Userdefault named "DocArray"

Refernce :- http://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html

Monday, July 25, 2011

Add a image layer over camera

ImagePicker = [[UIImagePickerController alloc] init];
ImagePicker.delegate = self;
#if TARGET_IPHONE_SIMULATOR
ImagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
#elif TARGET_OS_IPHONE
ImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
UIImageView *ImgOutline=[[UIImageView alloc] initWithFrame:CGRectMake(20, 28, 124, 404)];
ImgOutline.image=[UIImage imageNamed:@"outline.png"];
[ImagePicker.view addSubview:ImgOutline];
#endif

ImagePicker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
ImagePicker.editing = YES;
[self presentModalViewController:ImagePicker animated:YES];
[ImagePicker release];

Thursday, June 2, 2011

water effect with basic animation iphone sdk

I have found a good animation effect from google (Hidden Property)

CATransition *transition = [CATransition animation];
transition.type = @"rippleEffect";
transition.duration = 1.0f;
transition.timingFunction = UIViewAnimationCurveEaseInOut;
[self.view.layer addAnimation:transition forKey:@"transitionViewAnimation"];

we can use suckEffect and spewEffect similarly

Thursday, May 5, 2011

A Static Array That can be used anywhere in Application

1. Create a new plist file


named it suppose DictArr

2.

now add values in in this plist as


3.

Now where you wants to access these value
use This code
NSString *path = [[NSBundle mainBundle] pathForResource:@"DictArr" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
Arralbum=[dict objectForKey:@"ArrAlbum"];

Wednesday, February 2, 2011

Create Third Party Ads Through WebView

First we create a view controller named MyAds

in MyAds.h


@interface MyAds : UIViewController
{
IBOutlet UIWebView *Web_Ad;
NSString *formatStr;

UINavigationController *ng;
id parentController;

IBOutlet UIView *viewAdDesc;
IBOutlet UIWebView *Web_Ad_Detail;

}
-(void)initWithStr:(NSString*)str;
-(IBAction)btnCancel_Clicked:(id)sender;
@property(nonatomic, retain) id ParentController;
@property (nonatomic, retain) IBOutlet UINavigationController *ng;
@end


in MyAds.m


#import "MyAds.h"

@implementation MyAds
@synthesize ParentController = parentController;
@synthesize ng;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[Web_Ad setBackgroundColor:[UIColor clearColor]];
[Web_Ad setOpaque:NO];
[Web_Ad loadHTMLString:formatStr baseURL:[NSURL URLWithString:@"http://www.ashiphone.blogspot.com/"]];
}
-(void)initWithStr:(NSString*)str
{
formatStr=str;
[formatStr retain];
}

#pragma mark WebviewDelegate

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSLog(@"Page Start Loading");
if(webView==Web_Ad_Detail)
return YES;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSURL *urlReq=[request URL];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
if([urlReq isEqual:[NSURL URLWithString:@"http://www.ashiphone.blogspot.com/"]])
NSLog(@"YES");
else if(urlReq)
{
[Web_Ad stopLoading];
[Web_Ad loadHTMLString:formatStr baseURL:[NSURL URLWithString:@"http://www.ashiphone.blogspot.com/"]];
[parentController addSubview:viewAdDesc];
ng.navigationBarHidden = YES;
[Web_Ad_Detail loadRequest:request];
}
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{


}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{

}

-(IBAction)btnCancel_Clicked:(id)sender
{
[viewAdDesc removeFromSuperview];
ng.navigationBarHidden = NO;
}




- (void)viewDidUnload {
[super viewDidUnload];
}


- (void)dealloc {
[super dealloc];
}


@end




Now We Have To Include This View As SubView Where We Wants the Ads

MyAds* childObject = [[MyAds alloc]initWithNibName:@"MyAds" bundle:[NSBundle mainBundle]];
childObject.ParentController=self.view;
childObject.ng = self.navigationController;
[childObject initWithStr:formatStr];
// formatStr is NSString with HTML code