forked from NikolayShubenkovProgSchool/iProg0102_072015
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaunchOtherAppViewController.m
102 lines (58 loc) · 1.79 KB
/
LaunchOtherAppViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// LaunchOtherAppViewController.m
//
//
// Created by Nikolay Shubenkov on 11/07/15.
//
//
#import "LaunchOtherAppViewController.h"
#import "MBProgressHUD.h"
@interface LaunchOtherAppViewController ()
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberfield;
@end
@implementation LaunchOtherAppViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.phoneNumberfield.placeholder = @"Введите номер телефона";
}
- (IBAction)callToSomebodyPressed:(id)sender
{
NSLog(@"Call button pressed");
NSString *phoneNumber = self.phoneNumberfield.text;
if ([self contactEntered]){
NSString *url = [NSString stringWithFormat:@"skype://%@",phoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
else {
[self askToEnterContactName];
}
}
- (BOOL)contactEntered
{
return self.phoneNumberfield.text.length > 3;
}
- (void)askToEnterContactName
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Упс!"
message:@"Введите, пожалуйста имя контакта"
delegate:nil
cancelButtonTitle:@"Ok (" otherButtonTitles:@"Не хочу",@"Да, сэр", nil];
[alert show];
}
- (IBAction)showCalculatingProcess:(UIButton *)sender
{
[self showCalculatingSomething];
[self performSelector:@selector(calculationFinished)
withObject:self
afterDelay:4];
}
- (void)showCalculatingSomething
{
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
- (void)calculationFinished
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
@end