Sunteți pe pagina 1din 12

Ministerul Educaiei al Republicii Moldova

Universitatea Tehnic a Moldovei


Facultatea Calculatoare, Informatic i Microelectronic
Catedra Automatic i Tehnologii Informaionale

RAPORT
Disciplina: Programarea aplicatiilor incorporate si independente de platforma
Lucrare de laborator Nr.5
Tema: iOS

A efectuat:

st.Gr TI-121 A.Cobla

A verificat:

lector universitar I.Antohi

Chiinu 2014

Obiectivele lucrrii:
Dezvoltare a unei simple aplicaii pentru dispozitive iOS, utiliznd mediul de dezvoltare XCode .
Scopul:
De prezentat o aplicaie ce ruleaz pe un dispozitiv iOS sau Emulator, ce va con ine pe interfa a sa,
urmtoarele elemente:
1. patru butoane (ce vor executa condiiile de mai jos)
2. dou Radio butoane (pentru cei ce au 2 camere video)
Condiiile:
De utilizat 4 butoane (componente ui) pentru a reliza urmtoarele condiii:
1. De creat un push notification pe ecranul dispozitivului n cazul execuiei unui eveniment.
2. De utilizat browserul intern al dispozitivului, pentru a deschide o pagin web (adresa la dorin).
3. De rulat evenimentul de lucru a camerei frontale i/sau spate la selectarea unuia din 2 radio
butoane propuse.
4. Este un punct la dorina voastr (sau un brainstorming).

Relizarea sarcinii:
Dezvoltarea aplicaiilor pe iOS presupune utilizarea unui mediu de dezvoltare care ne permite s crem i
s rulm aplicaii pe acest sistem de operare.
Pentru a realiza aceast lucrare de laborator am folosit mediul de dezvoltare Xcode, care are integrat
pachetul iOS SDK.
Crearea unui nou proiect:
Pentru a crea o aplicaie android n Eclipse trebuie s accesm din meniu: File -> New Project i va
aprea o fereastr nou (vezi in Figura 1). n aceast fereastr mediul ne ofer posibilitatea de a alege
tipul proiectului, n cazul nostru iOS Single View Application.

Figura 1 Meniul de creare a unui nou proiect


Dup accesare va aprea o fereastr care cere s introducem numele aplicaiei (vezi in Figura 2).

Figura 2 Crearea unei aplicaii iOS


i ultimul pas va trebui s alegem locul de pstrare a proiectului nou creat (vezi Figura 3).

Figura 3 Finisarea crearea proiectului

Crearea aplicaiei:
Fiierul ViewController.h
//
//
//
//
//
//
//

ViewController.h
Lab1
Created by Adrian on 1/4/15.
Copyright (c) 2015 __MyCompanyName__. All rights reserved.

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property
@property
@property
@property
@property
@property
-

(weak,
(weak,
(weak,
(weak,
(weak,
(weak,

nonatomic)
nonatomic)
nonatomic)
nonatomic)
nonatomic)
nonatomic)

IBOutlet
IBOutlet
IBOutlet
IBOutlet
IBOutlet
IBOutlet

UIImageView *imageView;
UIButton *NotificationButton;
UIButton *OpenUrlButton;
UIButton *ChoosePhotoButton;
UIButton *TakePhotoButton;
UIButton *AnimationButton;

(IBAction)NotificationButtonAction:(id)sender;
(IBAction)OpenUrlButtonAction:(id)sender;
(IBAction)getPhoto:(id)sender;
(IBAction)AnimationButtonAction:(id)sender;

@end

Fiierul ViewController.m
//
//
//
//
//
//
//

ViewController.m
Lab1
Created by Adrian on 1/4/15.
Copyright (c) 2015 __MyCompanyName__. All rights reserved.

#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize imageView;
@synthesize NotificationButton;
@synthesize OpenUrlButton;
@synthesize ChoosePhotoButton;
@synthesize TakePhotoButton;
@synthesize AnimationButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage *backgroundImage = [UIImage imageNamed:@"BackgroundPattern.png"];
UIColor *backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
self.view.backgroundColor = backgroundColor;

UIImage *buttonNormalImage = [UIImage imageNamed:@"BlueButtonDefault"];


UIImage *buttonNormalStretchableImage = [buttonNormalImage
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
UIImage *buttonHighlightedImage = [UIImage imageNamed:@"BlueButtonHighlighted"];
UIImage *buttonHighlightedStretchableImage = [buttonHighlightedImage
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[self.NotificationButton setBackgroundImage:buttonNormalStretchableImage
forState:UIControlStateNormal];
[self.NotificationButton setBackgroundImage:buttonHighlightedStretchableImage
forState:UIControlStateHighlighted];
[self.OpenUrlButton setBackgroundImage:buttonNormalStretchableImage
forState:UIControlStateNormal];
[self.OpenUrlButton setBackgroundImage:buttonHighlightedStretchableImage
forState:UIControlStateHighlighted];
[self.ChoosePhotoButton setBackgroundImage:buttonNormalStretchableImage

forState:UIControlStateNormal];
[self.ChoosePhotoButton setBackgroundImage:buttonHighlightedStretchableImage
forState:UIControlStateHighlighted];
[self.TakePhotoButton setBackgroundImage:buttonNormalStretchableImage
forState:UIControlStateNormal];
[self.TakePhotoButton setBackgroundImage:buttonHighlightedStretchableImage
forState:UIControlStateHighlighted];
[self.AnimationButton setBackgroundImage:buttonNormalStretchableImage
forState:UIControlStateNormal];
[self.AnimationButton setBackgroundImage:buttonHighlightedStretchableImage
forState:UIControlStateHighlighted];
}
- (void)viewDidUnload
{
[self setImageView:nil];
[self setNotificationButton:nil];
[self setOpenUrlButton:nil];
[self setTakePhotoButton:nil];
[self setChoosePhotoButton:nil];
[self setAnimationButton:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (IBAction)NotificationButtonAction:(id)sender {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Notificare"
message:@"Exemplu de notificare" delegate: nil cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
- (IBAction)OpenUrlButtonAction:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:@"https://www.google.com"]];
}
//http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-orcamera-using-uiimagepickercontroller/
- (IBAction)getPhoto:(id)sender {

UIImagePickerController * picker = [[UIImagePickerController alloc] init];


picker.delegate = self;
if((UIButton *) sender == ChoosePhotoButton) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == FALSE)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Eroare"
message:@"Dispozitivul nu are camera." delegate: nil cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
return;
}
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
- (IBAction)AnimationButtonAction:(id)sender {
SecondViewController *SecondViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"SecondViewController"];
[self.navigationController pushViewController:SecondViewController animated:YES];
}
@end

Fiierul SecondViewController.h
//
//
//
//
//
//
//

SecondViewController.h
Lab1
Created by Adrian on 1/4/15.
Copyright (c) 2015 __MyCompanyName__. All rights reserved.

#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *AnimatedPicture;

@end

Fiierul SecondViewController.m
//
//
//
//
//
//
//

SecondViewController.m
Lab1
Created by Adrian on 1/4/15.
Copyright (c) 2015 __MyCompanyName__. All rights reserved.

#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
@synthesize AnimatedPicture;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImage *backgroundImage = [UIImage imageNamed:@"BackgroundPattern2.png"];
UIColor *backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
self.view.backgroundColor = backgroundColor;

// Release any retained subviews of the main view.


AnimatedPicture.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"win_1.png"],
[UIImage imageNamed:@"win_2.png"],
[UIImage imageNamed:@"win_3.png"],
[UIImage imageNamed:@"win_4.png"],
[UIImage imageNamed:@"win_5.png"],
[UIImage imageNamed:@"win_6.png"],
[UIImage imageNamed:@"win_7.png"],
[UIImage imageNamed:@"win_8.png"],
[UIImage imageNamed:@"win_9.png"],
[UIImage imageNamed:@"win_10.png"],
[UIImage imageNamed:@"win_11.png"],
[UIImage imageNamed:@"win_12.png"],

[UIImage
[UIImage
[UIImage
[UIImage

imageNamed:@"win_13.png"],
imageNamed:@"win_14.png"],
imageNamed:@"win_15.png"],
imageNamed:@"win_16.png"],nil];

[AnimatedPicture setAnimationRepeatCount:0];
AnimatedPicture.AnimationDuration = 0.8;
[AnimatedPicture startAnimating];
}
- (void)viewDidUnload
{
[self setAnimatedPicture:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end

Interfaa aplicaiei:

Figura 4 Interfaa aplicaiei

Figura 5 Interfaa aplicaiei

Concluzii:
Efectund aceast lucrare de laborator mi-am ntrit cunotine n domeniul programrii aplica iilor
incorporate si independente de platform i n deosebi despre sistemul de operare iOS. Am instalat
mediul de dezvoltare XCode i m-am familarizat cu cele mai importante componente ale lui. Am aflat
cum se creaz un proiect iOS i cum se lanseaza o aplicaie pe emulator.

n procesul de creare a aplicaiei am nsuit modul grafic de creare a interfe ei cu ajutorul


elementelor, pe care le pune la dispoziie mediul de dezvoltare i am creat evenimente pentru toate aceste
elemente.