CS175
Chris Pollett
Oct 20, 2014
#import "ViewController.h"
#import "BlueViewController.h"
#import "YellowViewController.h"
@interface ViewController ()
@property (strong, nonatomic) YellowViewController *yellowViewController;
@property (strong, nonatomic) BlueViewController *blueViewController;
@end
@implementation ViewController
-(IBAction)switchViews:(id)sender
{
}
@end
#import "ViewController.h"
#import "BlueViewController.h"
#import "YellowViewController.h"
@interface ViewController ()
@property (strong, nonatomic) YellowViewController *yellowViewController;
@property (strong, nonatomic) BlueViewController *blueViewController;
@end
@implementation ViewController
-(IBAction)switchViews:(id)sender
{
if(!self.yellowViewController.view.superview) {
if(!self.yellowViewController) {
self.yellowViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"Yellow"];
}
[self.blueViewController.view removeFromSuperview];
[self.view insertSubview:self.yellowViewController.view atIndex:0];
} else {
if(!self.blueViewController) {
self.blueViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"Blue"];
}
[self.yellowViewController.view removeFromSuperview];
[self.view insertSubview:self.blueViewController.view atIndex:0];
}
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.blueViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"Blue"];
// initial use blue view
[self.view insertSubview:self.blueViewController.view atIndex: 0];
//index 0 behind everything
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
if(!self.blueViewController.view.superview) {
self.blueViewController = nil;
} else {
self.yellowViewController = nil;
}
}
@end
#import <UIKit/UIKit.h> @interface BlueViewController : UIViewController -(IBAction) blueButtonPressed: (id) sender; @end
#import "BlueViewController.h"
@implementation BlueViewController
-(IBAction) blueButtonPressed:(id) sender
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Blue View Button Pressed"
message:@"You pressed the button on the blue view"
delegate:nil
cancelButtonTitle:@"Yep, I did"
otherButtonTitles:nil];
[alert show];
}
//... unchanged boiler plate
@end
-(IBAction)switchViews:(id)sender
{
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
// next control speed at begin and end of animation
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if(!self.yellowViewController.view.superview) {
if(!self.yellowViewController) {
self.yellowViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"Yellow"];
}
[self.blueViewController.view removeFromSuperview];
[self.view insertSubview:self.yellowViewController.view atIndex:0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache: YES];
/*
Other possibilities:
UIViewAnimationTransitionFlipFromLeft
UIViewAnimationTransitionCurlUp
UIViewAnimationTransitionCurlDown
*/
} else {
if(!self.blueViewController) {
self.blueViewController = [self.storyboard
instantiateViewControllerWithIdentifier:@"Blue"];
}
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache: YES];
[self.yellowViewController.view removeFromSuperview];
[self.view insertSubview:self.blueViewController.view atIndex:0];
}
[UIView commitAnimations];
}
Which of the following is true?
GET / HTTP/1.0 newline newline
HTTP/1.1 200 OK Date: Wed, 07 Oct 2009 18:11:01 GMT Server: Apache/2.2.0 (Fedora) Last-Modified: Mon, 17 Nov 2008 23:09:56 GMT ETag: "f5678-2723-ad5ef900" Accept-Ranges: bytes Content-Length: 10019 Connection: close Content-Type: text/html ...CS Department homepage
@Override
public void onStart()
{
super.onStart();
ConnectivityManager cMgr = (ConnectivityManager)
this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cMgr.getActiveNetworkInfo();
this.status.setText(netInfo.toString());
}
<uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"> The first is for general networking, the second is for the actual info we have above.