Created
October 14, 2013 03:30
-
-
Save andrewschreiber/6970283 to your computer and use it in GitHub Desktop.
Code for disappearing (apologies for the hackiness)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RAAdLib.h | |
// Rally | |
// | |
// Created by Andrew Schreiber on 10/12/13. | |
// Copyright (c) 2013 Andrew Schreiber. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
#import "RAAppDelegate.h" | |
@interface RAAdLib : UIViewController <UITextFieldDelegate> | |
@property (weak, nonatomic)IBOutlet UIButton *nounButton; | |
@property (weak, nonatomic)IBOutlet UIButton *adjButton; | |
@property (weak, nonatomic)IBOutlet UIButton *verbButton; | |
@property (weak, nonatomic)IBOutlet UILabel *midline; | |
@property (weak, nonatomic)IBOutlet UILabel *wordType; | |
@property (weak, nonatomic)IBOutlet UITextField *textField; | |
@property (weak, nonatomic)IBOutlet UILabel *leftBar; | |
@property (weak, nonatomic)IBOutlet UILabel *topBar; | |
@property (weak, nonatomic)IBOutlet UILabel *rightBar; | |
@property (weak, nonatomic)IBOutlet UILabel *bottomBar; | |
@property (weak, nonatomic)NSArray *adLib1; | |
@property (weak, nonatomic)NSArray *adLib2; | |
@property (weak, nonatomic)NSArray *adLib3; | |
@property (weak, nonatomic)NSArray *adLib4; | |
@property (weak, nonatomic)NSArray *adLib5; | |
-(void)callLib; | |
- (void)callAdLib1; | |
- (void)callAdLib2; | |
- (void)callAdLib3; | |
- (void)callAdLib4; | |
- (void)callAdLib5; | |
-(void)nextEntry; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RAAdLib.m | |
// Rally | |
// | |
// Created by Andrew Schreiber on 10/12/13. | |
// Copyright (c) 2013 Andrew Schreiber. All rights reserved. | |
// | |
#import "RAAdLib.h" | |
@interface RAAdLib () | |
{ | |
int selected; | |
int currentLib; | |
} | |
@end | |
@implementation RAAdLib | |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | |
{ | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
// Custom initialization | |
} | |
return self; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
//Setup | |
([[UIApplication sharedApplication] setStatusBarHidden:YES | |
withAnimation:UIStatusBarAnimationFade]); | |
[self.textField becomeFirstResponder]; | |
self.textField.delegate = self; | |
self.textField.clearsOnBeginEditing=NO; | |
self.textField.clearsContextBeforeDrawing=NO; | |
self.textField.clearsOnInsertion=NO; | |
RAAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; | |
appDelegate.entryStrings = [[NSMutableArray alloc]initWithArray:@[@"one",@"two",@"three"]]; | |
NSLog(@"entrystrings: %@",appDelegate.entryStrings); | |
selected=1; | |
[self setupLibs]; | |
[self callLib]; | |
} | |
-(void)setBorderBoxPosition:(NSInteger)position | |
{ | |
[UIView animateWithDuration:0.2 | |
delay: 0 | |
options: UIViewAnimationOptionCurveLinear | |
animations:^{ | |
if(position==1) | |
{ | |
self.bottomBar.frame=CGRectMake(20, 257, 35, 1); | |
self.topBar.frame=CGRectMake(20, 222, 35, 1); | |
} | |
else if(position==2) | |
{ | |
self.bottomBar.frame=CGRectMake(143, 257, 35, 1); | |
self.topBar.frame=CGRectMake(143, 222, 35, 1); | |
}else if (position==3) | |
{ | |
self.bottomBar.frame=CGRectMake(265, 257, 35, 1); | |
self.topBar.frame=CGRectMake(265, 222, 35, 1); | |
} | |
} | |
completion:^(BOOL finished){ | |
}]; | |
if(position==1) | |
{ | |
self.leftBar.frame=CGRectMake(20, 222, 1, 35); | |
self.rightBar.frame=CGRectMake(54, 222, 1, 35); | |
} | |
else if(position==2) | |
{ | |
self.leftBar.frame=CGRectMake(177, 222, 1, 35); | |
self.rightBar.frame=CGRectMake(143, 222, 1, 35); | |
}else if (position==3) | |
{ | |
self.leftBar.frame=CGRectMake(265, 222, 1, 35); | |
self.rightBar.frame=CGRectMake(299, 222, 1, 35); | |
} | |
} | |
- (void) callLib | |
{ | |
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; | |
currentLib= [defaults integerForKey:@"currentLib"]; | |
NSString *libString = [@"adLib" stringByAppendingString:[NSString stringWithFormat:@"%d", currentLib]]; | |
if ([libString isEqualToString:@"adLib1"]){ | |
[self callAdLib1]; | |
}else if ([libString isEqualToString:@"adLib2"]){ | |
[self callAdLib2]; | |
}else if ([libString isEqualToString:@"adLib3"]){ | |
[self callAdLib3]; | |
}else if ([libString isEqualToString:@"adLib4"]){ | |
[self callAdLib4]; | |
}else if ([libString isEqualToString:@"adLib5"]){ | |
[self callAdLib5]; | |
} | |
} | |
- (void)callAdLib1 | |
{ | |
selected=1; | |
self.wordType.text=[self.adLib1 objectAtIndex:1]; | |
NSLog(@"wordType %@",self.wordType.text); | |
NSLog(@"object %@",[self.adLib1 objectAtIndex:1]); | |
self.textField.placeholder = @"i.e. cutiepie"; | |
self.nounButton.hidden = NO; | |
self.adjButton.hidden = YES; | |
self.verbButton.hidden= YES; | |
[self setBorderBoxPosition:selected]; | |
} | |
- (void)callAdLib2 | |
{ | |
selected=1; | |
self.wordType.text=[self.adLib2 objectAtIndex:1]; | |
self.textField.placeholder = @"i.e. the disco"; | |
self.nounButton.hidden = NO; | |
self.adjButton.hidden= YES; | |
self.verbButton.hidden = YES; | |
[self setBorderBoxPosition:selected]; | |
} | |
- (void)callAdLib3 | |
{ | |
NSLog(@"Selected in lib: %d",selected); | |
if (selected ==3) {selected =1;} | |
if(selected==2){ | |
self.wordType.text=[self.adLib3 objectAtIndex:1]; | |
self.textField.placeholder = @"i.e. janky"; | |
} | |
else if(selected==1){ | |
self.wordType.text=[self.adLib3 objectAtIndex:2]; | |
self.textField.placeholder = @"i.e. eyebrow"; | |
} | |
self.nounButton.hidden = NO; | |
self.adjButton.hidden= NO; | |
self.verbButton.hidden = YES; | |
[self setBorderBoxPosition:selected]; | |
} | |
- (void)callAdLib4 | |
{ | |
if (selected ==2) {selected =3;} | |
if(selected==1){ | |
self.wordType.text=[self.adLib3 objectAtIndex:1]; | |
self.textField.placeholder = @"i.e. zebra"; | |
} | |
else if(selected ==3) | |
{ | |
self.wordType.text=[self.adLib3 objectAtIndex:2]; | |
self.textField.placeholder = @"i.e. explode"; | |
} | |
self.nounButton.hidden = NO; | |
self.adjButton.hidden= YES; | |
self.verbButton.hidden = NO; | |
[self setBorderBoxPosition:selected]; | |
} | |
- (void)callAdLib5 | |
{ | |
if (selected ==1) {selected =2;} | |
if(selected==2){ | |
self.wordType.text=[self.adLib3 objectAtIndex:1]; | |
self.textField.placeholder = @"i.e. adorable"; | |
} | |
else if(selected ==3) | |
{ | |
self.wordType.text=[self.adLib3 objectAtIndex:2]; | |
self.textField.placeholder = @"i.e. dance"; | |
} | |
self.nounButton.hidden = YES; | |
self.adjButton.hidden= NO; | |
self.verbButton.hidden = NO; | |
[self setBorderBoxPosition:selected]; | |
} | |
- (IBAction)nounPress:(id)sender | |
{ | |
selected=1; | |
[self callLib]; | |
} | |
- (IBAction)adjPress:(id)sender | |
{ | |
selected=2; | |
[self callLib]; | |
} | |
- (IBAction)verbPress:(id)sender | |
{ | |
selected=3; | |
[self callLib]; | |
} | |
- (void)setupLibs | |
{ | |
self.adLib1= [NSArray arrayWithObjects:@"n",@"Pet name" , nil]; // Good morning, [PA] | |
self.adLib2 = [NSArray arrayWithObjects:@"n",@"Place", nil]; //Time to get ready for [place] | |
self.adLib3 = [NSArray arrayWithObjects:@"an", @"Adjective",@"Body Part" , nil]; //Get your [A] [BP] out of bed | |
self.adLib4 = [NSArray arrayWithObjects:@"nv",@"Noun",@"Bad action", nil]; //If you don't get out of bed, a [noun] will [bad action] | |
self.adLib5 = [NSArray arrayWithObjects:@"av",@"Positive Adjective",@"Action verb", nil]; //Its so [pa] when you [av] in your sleep | |
selected=1; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (BOOL)textFieldShouldReturn:(UITextField *)textFielder { | |
[self nextEntry]; | |
return YES; | |
} | |
-(void)nextEntry | |
{ | |
NSString *textString = self.textField.text; | |
RAAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; | |
[appDelegate.entryStrings replaceObjectAtIndex:selected-1 withObject:textString]; | |
NSLog(@"entrystrings: %@",appDelegate.entryStrings); | |
self.textField.text= @""; | |
selected = selected +1; | |
if (selected==4){ | |
selected=1;} | |
[self callLib]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment