Archive for category iOS

Open A Link in Safari from Your iPhone Application

A very basic functionality you can add in your application. this post is all about how can you push a link on the Safari from your application.

Implementation is pretty simple. You have to use openURL and bang you are done with it. Here is the example :-

-(IBAction)pushToSafari

{

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.google.co.uk"]];

}

Hope it helps.

, , ,

Leave a comment

Take Screen-shot of Current View and Attach it to Mail

Hello Everyone,

This is my first tutorial for iOS Developers. I am starting with the very basic application cum functionality which is “How to take screen-shot of the current view and attaching it to the mail?”.

I have made a separate class named “CommonAPI” which will be very easy to use in your projects.

In this CommonAPI class I have written the methods which will get the screenshots and simply give the image to you. Then you can do whatever you want.

CommonAPI.h

#import <Foundation/Foundation.h>

@interface CommanAPI : NSObject {

}

//+ (UIViewController*)viewController:(UIView*)iView;

+ (UIImage*)makeScreenShot:(UIView*)iView;

+(float)degreesToRadian:(float)x;

@end

CommonAPI.m

#import "CommanAPI.h"

#import <QuartzCore/QuartzCore.h>

@implementation CommanAPI

+ (UIViewController*)viewController:(UIView*)iView{

for (UIView* next = [iView superview]; next; next = next.superview) {

UIResponder* nextResponder = [next nextResponder];

if ([nextResponder isKindOfClass:[UIViewController class]]) {

return (UIViewController*)nextResponder;

}

}

return nil;

}

+(UIImage*)makeScreenShot:(UIView*)iView{

UIGraphicsBeginImageContext(iView.frame.size);

[iView.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *tmpImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return tmpImage;

}

+(float)degreesToRadian:(float)x{

return (M_PI * (x) / 180.0);

}

@end

Download Source Codehttps://github.com/akshaythakur/AttachScreenShotinMail/tree/code

Output :-

This slideshow requires JavaScript.

Leave a comment