Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // PostViewController.m
- // Berry
- //
- // Created by Tommie Carter on 9/8/12.
- // Copyright (c) 2012 Tommie Carter. All rights reserved.
- //
- #import "PostViewController.h"
- @interface PostViewController ()
- @end
- @implementation PostViewController
- @synthesize popoverContent, popViewController;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(willEnterForegroundNotification:)
- name:UIApplicationWillEnterForegroundNotification
- object:nil];
- [[NSNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(willResignActiveNotification:)
- name:UIApplicationWillResignActiveNotification
- object:nil];
- // Do any additional setup after loading the view.
- }
- - (void)willEnterForegroundNotification:(NSNotification *)notification
- {
- //
- }
- - (void)willResignActiveNotification:(NSNotification *)notification
- {
- [self setPopoverContent:nil];
- }
- -(void)didReceiveMemoryWarning{
- [super didReceiveMemoryWarning];
- //release stuff
- }
- - (void)viewDidUnload
- {
- [self setPopoverContent:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (void)viewWillAppear:(BOOL)animated{
- }
- - (void)viewDidAppear:(BOOL)animated{
- }
- - (void)viewWillDisappear:(BOOL)animated{
- }
- - (void)viewDidDisappear:(BOOL)animated{
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- /* Called on the delegate when the popover controller will dismiss the popover. Return NO to prevent the dismissal of the view.
- */
- - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{
- return YES;
- }
- /* Called on the delegate when the user has taken action to dismiss the popover. This is not called when -dismissPopoverAnimated: is called directly.
- */
- - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{
- }
- - (IBAction)showPopContentView:(id)sender {
- UIButton *popContentButton = (UIButton*)sender;
- if (![self popoverContent])
- {
- switch (popContentButton.tag) {
- case 100:
- popoverContent = (ClientViewController*)[[self storyboard]instantiateViewControllerWithIdentifier:@"ClientViewController"];
- break;
- case 101:
- popoverContent = (MatterViewController*)[[self storyboard]instantiateViewControllerWithIdentifier:@"MatterViewController"];
- break;
- case 102:
- popoverContent = (ActivityViewController*)[[self storyboard]instantiateViewControllerWithIdentifier:@"ActivityViewController"];
- break;
- case 103:
- popoverContent = (TaskViewController*)[[self storyboard]instantiateViewControllerWithIdentifier:@"TaskViewController"];
- break;
- default:
- NSLog(@"%s ; BAD POPOVER BUTTON POINTER",__PRETTY_FUNCTION__);
- break;
- }
- popoverContent.contentSizeForViewInPopover = CGSizeMake(320.0,299.0);
- //popViewController is also a property
- popViewController = [[UIPopoverController alloc]
- initWithContentViewController:popoverContent];
- }
- // Perform setup on the fancy controller you want to do every
- // time the action gets triggered here. Do initialization in the if
- // block above.
- // Now display the popover from the sender's frame.
- [popViewController presentPopoverFromRect:popContentButton.frame
- inView:[self view]
- permittedArrowDirections:UIPopoverArrowDirectionAny
- animated:YES];
- popoverContent = nil;
- popContentButton = nil;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment