-
Notifications
You must be signed in to change notification settings - Fork 0
/
SchoolTableViewCell.m
executable file
·101 lines (79 loc) · 3.58 KB
/
SchoolTableViewCell.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// SchoolTableViewCell.m
// Login
//
// Created by Dev on 10/26/14.
// Copyright (c) 2014 Dev. All rights reserved.
//
#import "SchoolTableViewCell.h"
#import <Parse/Parse.h>
@implementation SchoolTableViewCell
- (void)awakeFromNib {
// Initialization code
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
UIDevice * device = [UIDevice currentDevice];
if(device.orientation == UIDeviceOrientationLandscapeRight || device.orientation == UIDeviceOrientationLandscapeLeft ){
[self orientationChanged:[NSNotification notificationWithName:@"-" object:device]];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void) orientationChanged:(NSNotification *)note
{
// NSLog(@"Orientation Changed! from cell");
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationPortrait:
self.followButton.frame = CGRectMake(226, 26, 86, 30);
self.name.frame = CGRectMake(77, 12, 129, 53);
break;
case UIDeviceOrientationLandscapeRight:
case UIDeviceOrientationLandscapeLeft:
self.followButton.frame = CGRectMake(400, 26, 86, 30);
self.name.frame = CGRectMake(77, 12, 200, 53);
break;
default:
break;
};
}
- (IBAction)follow:(UIButton *)sender {
// NSLog(@"Pressed and tag = %d", sender.tag);
//NSLog(@"Selected: %d and %s",sender.tag, [[parentTable description] UTF8String]);
if(self.tag != 1){
//NSLog(@"cell %d that cell is NOT selected", sender.tag);
//self.name.textColor = [UIColor redColor];
self.tag = 1;
[self.followButton setTitle:@"Scouting" forState:UIControlStateNormal];
[self.followButton setBackgroundImage:[UIImage imageNamed:@"following_bttn.png"] forState:UIControlStateNormal];
// PFInstallation *currentInstallation = [PFInstallation currentInstallation];
// [currentInstallation addUniqueObject:self.name.text forKey:@"channels"];
// [currentInstallation saveInBackground];
[[PFUser currentUser]addUniqueObject:self.name.text forKey:@"follows"];
[[PFUser currentUser]save];
}else if(self.tag == 1){
//NSLog(@"cell %d that cell is selected",sender.tag);
//self.name.textColor = [UIColor whiteColor];
UIActionSheet *confirmation = [[UIActionSheet alloc]initWithTitle:self.name.text delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Stop Scouting" otherButtonTitles:nil];
[confirmation showFromRect:CGRectMake(320, 480, 320, 50) inView:self.superview animated:YES];
}
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 0){
self.tag = 0;
[self.followButton setTitle:@"Prospect" forState:UIControlStateNormal];
[self.followButton setBackgroundImage:[UIImage imageNamed:@"follow_bttn.png"] forState:UIControlStateNormal];
// PFInstallation *currentInstallation = [PFInstallation currentInstallation];
// [currentInstallation removeObject:self.name.text forKey:@"channels" ];
// [currentInstallation saveInBackground];
//
[[PFUser currentUser] removeObject :self.name.text forKey:@"follows"];
[[PFUser currentUser]save];
}
}
@end