Skip to content

Instantly share code, notes, and snippets.

View casspangell's full-sized avatar

mondousage casspangell

View GitHub Profile
//allocate the view that contains the popup
popUpView = [[UIView alloc] initWithFrame:CGRectMake(POPUP_X, POPUP_Y, POPUP_WIDTH, POPUP_HEIGHT)];
popUpView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:popUpView];
UIButton *clickHere = [UIButton buttonWithType:UIButtonTypeCustom];
clickHere.frame = popUpView.frame;
clickHere.backgroundColor = [UIColor redColor];
[popUpView addSubview:clickHere];
[clickHere setTitle:@"Click Here" forState:UIControlStateNormal];
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"scroller.png"]];
imageView.frame = CGRectMake(0, 375, kScrollObjWidth, kScrollObjHeight);
[scroller addSubview:imageView];
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(kScrollObjWidth, kScrollObjHeight)];
[scroller addSubview:imageView];
@casspangell
casspangell / gist:2416886
Created April 18, 2012 21:57
Some Xcode Keyboard Delegates
#pragma mark - keyboard delegates
-(void) textFieldDidBeginEditing:(UITextField *)textFieldView
{
currentTextField = textFieldView;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if(textField == titleOfImageTextField)
@casspangell
casspangell / gist:2500879
Created April 26, 2012 16:43
JSON trial and error
- (void) getJSON {
// Create the request.
NSURLRequest *urlRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.zeroeightysix.com/Logovision/jsonhotspotting.json"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
//Create queue
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
// JSON as a NSData object
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
@casspangell
casspangell / FirstViewController.h
Created May 7, 2012 00:17
Switching Views in iOS
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
}
//Add the IBAction to the button to switch views
-(IBAction)goToViewTwo:(id)sender;
@end
//Other class.h
//Include the needed method's class's .h
#import "AppDelegate.h"
@interface aWebView : UIViewController {
//Create the delegate
AppDelegate *appDelegate;
}
//OtherClass.m
@implementation ProjectsViewController
@synthesize imageView, swipeUpGR, theProjects, tapGR, arrayOfImages;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// Custom initialization
@casspangell
casspangell / gist:2638605
Created May 8, 2012 19:17
Instantiating a Nib of Another Class
//Create the pointer to the view you want to become the current
LoginWindow *loginViewController = [[LoginWindow alloc] initWithNibName:@"LoginWindow~iphone" bundle:nil];
//Change current view to the new one
self.window.rootViewController = loginViewController;
@casspangell
casspangell / gist:2648758
Created May 9, 2012 20:56
Follow/Unfollow
- (void) followUser:(NSString *)user andPass:(NSString *)pass andFolloweeId:(NSString *)followeeId
{
NSString *apiCall = [NSString stringWithFormat:@"api2/doFollow?"];
NSURL *url = [NSURL URLForContent:apiCall];
NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
NSString *postData = [NSString stringWithFormat:@"username=%@&password=%@&follow=%@",user, pass, followeeId];
@casspangell
casspangell / gist:2654374
Created May 10, 2012 16:40
Set status bar hidden
//The status bar is at the top of the iPhone 20px
[[UIApplication sharedApplication] setStatusBarHidden:YES];