//Download image from HTTP server
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/intl/en_ALL/images/logo.gif"]];
UIImage *image = [UIImage imageWithData:imageData];
read more//Download image from HTTP server
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com/intl/en_ALL/images/logo.gif"]];
UIImage *image = [UIImage imageWithData:imageData];
read more
//This example send email with attachment using server side
//So iPhone will fill form and send proper request to web server using POST method
//For test you can use attached sendEmail.php
-(NSMutableData *)generateDataFromText:(NSString *)dataText fieldName:(NSString *)fieldName{
NSString *post = [NSString stringWithFormat:@"--AaB03x\r\nContent-Disposition: form-data; name=\"%@\"\r\n ...
read moreUILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 70)]; label.numberOfLines = 2; label.text = @"text"; label.backgroundColor = [UIColor clearColor]; label.textColor = [UIColor whiteColor]; label.highlightedTextColor = [UIColor blackColor]; label.textAlignment = UITextAlignmentLeft; label.font = [UIFont systemFontOfSize:12]; //rotate label in 45 degrees label.transform = CGAffineTransformMakeRotation( M_PI/4 ); [self addSubview:label]; [label ...
-(BOOL)addImage:(UIImage *)imageItem{
int pegId = [self getNewjm_pegID];
if (!dbOpen) {
[self openDb];
}
NSString *insertProgrammeSql = @"INSERT INTO images (image) VALUES (?)";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [insertProgrammeSql cStringUsingEncoding:NSUTF8StringEncoding], -1, &statement, NULL) == SQLITE_OK) {
NSData *imageData = UIImagePNGRepresentation(pegItem.albumCover);
sqlite3_bind_blob(statement, 1, [imageData bytes], [imageData length], SQLITE_TRANSIENT);
sqlite3_step(statement);
}
[self closeDb];
return YES ...
read more//Include files from attached archive
#import "ZipArchive.h"
NSString *filePath = @"/Users/alex/Test/04/zTest/test.zip";
ZipArchive *z = [[ZipArchive alloc] init];
[z UnzipOpenFile:filePath];
[z UnzipFileTo:@"/Users/alex/Test/04" overWrite:YES];
[z UnzipCloseFile];
//need to add: AVFoundation.framework
#import <AVFoundation/AVAudioPlayer.h>
NSBundle *mainBundle = [NSBundle mainBundle];
NSURL *url = [NSURL fileURLWithPath:[mainBundle pathForResource:@"game" ofType:@"mp3"] isDirectory:NO];
AVAudioPlayer *gameSoundTrack = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[gameSoundTrack prepareToPlay];
[gameSoundTrack play];
read more-(UIImage *)addCircle:(UIImage *)img radius:(CGFloat)radius latCon:(CGFloat)lat lonCon:(CGFloat)lon{
int w = img.size.width;
int h = img.size.height;
lon = h - lon;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
//draw the circle
CGContextDrawImage(context, CGRectMake(0, 0, w, h ...
read more//Add text to UIImage
-(UIImage *)addText:(UIImage *)img text:(NSString *)text1{
int w = img.size.width;
int h = img.size.height;
//lon = h - lon;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), img.CGImage);
CGContextSetRGBFillColor(context, 0 ...
read more//Resize image and keep aspect ratio
-(UIImage *)resizeImage:(UIImage *)image {
int w = image.size.width;
int h = image.size.height;
CGImageRef imageRef = [image CGImage];
int width, height;
int destWidth = 640;
int destHeight = 480;
if(w > h){
width = destWidth;
height = h*destWidth/w;
} else {
height = destHeight;
width = w*destHeight/h;
}
CGColorSpaceRef ...
read more//h file
@interface TestViewController : UIViewController<UITextFieldDelegate> {
CGFloat animatedDistance;
}
//m file
- (void)textFieldDidBeginEditing:(UITextField *)textField{
static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 162;
CGRect textFieldRect =
[self.view.window convertRect:textField.bounds ...
read more