Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Pop up UIViewController with an IBAction UIViewController not functioning

UI button freezes when I click on it any help on what I could do to resolve this problem.

 @interface MainViewController : UIViewController <LoginDelegate,WEPopoverParentView,PopoverControllerDelegate,MainMenuDelegate,MKMapViewDelegate,UIActionSheetDelegate,UIAccelerometerDelegate, CLLocationManagerDelegate, NSObject>
        {
            AppDelegate *appDelegate;
            IBOutlet MKMapView *userMap;
            CLLocationManager *locationManager;

        }
        @property (strong, nonatomic) IBOutlet UILabel *speedView;
        @property(nonatomic) int speedCount;
    @property (nonatomic,retain) CLLocationManager *locationManager;
    @property (nonatomic, strong) WEPopoverController *popoverController;

    + (NSString *) speedToMPH: (float) value;


    - (IBAction)btnMenuTapped:(id)sender;

    - (IBAction)btnMenuTapped:(id)sender
    {
        if (self.popoverController)
        {
              [self.popoverController dismissPopoverAnimated:YES];
              self.popoverController = nil;
         }
        else
        {
              MainMenuViewController *contentViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
              contentViewController.delegate = self;

              self.popoverController = [[WEPopoverController alloc] initWithContentViewController:contentViewController];

            self.popoverController.delegate = self;
            self.popoverController.popoverContentSize = contentViewController.view.frame.size;

              [self.popoverController presentPopoverFromRect:[sender frame]
                                                                inView:self.view
                                         permittedArrowDirections:UIPopoverArrowDirectionDown
                                                             animated:YES];

         }
    }

    #pragma mark - WEPopover Controller Delegate

- (BOOL)popoverControllerShouldDismissPopover:(WEPopoverController *)popoverController
{
      // self.popoverController = nil;
    return YES;
}

-(void)popoverControllerDidDismissPopover:(WEPopoverController *)popoverController
{
    self.popoverController = nil;
}

#pragma mark - Mainmenu Delegate

-(void)tappedButtonTag:(NSInteger)pintButtonTag
{
    [self.popoverController dismissPopoverAnimated:YES];
    self.popoverController = nil;

    if (pintButtonTag==2)
    {
        TravelLogViewController *objTravelLogViewController = [[TravelLogViewController alloc] initWithNibName:@"TravelLogViewController" bundle:nil];
        [self.navigationController pushViewController:objTravelLogViewController animated:YES];
        [objTravelLogViewController release];
    }
    else if(pintButtonTag == 3)
    {
        HelpFromOtherUsersViewController *objHelpFromOtherUsersViewController = [[HelpFromOtherUsersViewController alloc] initWithNibName:@"HelpFromOtherUsersViewController" bundle:nil];
        [self.navigationController pushViewController:objHelpFromOtherUsersViewController animated:YES];
        [objHelpFromOtherUsersViewController release];
    }
    else if (pintButtonTag==4)
    {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"GasIt Community" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Traffic Report",@"Get Assistance",@"Question List", nil];
        actionSheet.tag = 1;
        actionSheet.delegate = self;
        actionSheet.actionSheetStyle =  UIActionSheetStyleBlackTranslucent;
        [actionSheet showInView:self.view];
    }
    else if(pintButtonTag == 5)
    {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Car" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Car Problems",@"Report Car Problem",@"Parking Notification", nil];
        actionSheet.tag = 2;
        actionSheet.delegate = self;
        actionSheet.actionSheetStyle =  UIActionSheetStyleBlackTranslucent;
        [actionSheet showInView:self.view];
    }
    else if(pintButtonTag == 6)
    {
        LostUserListViewController *objLostUserListViewController = [[LostUserListViewController alloc] initWithNibName:@"LostUserListViewController" bundle:nil];
        [self.navigationController pushViewController:objLostUserListViewController animated:YES];
        [objLostUserListViewController release];
    }
    else if(pintButtonTag == 7)
    {
        WeatherViewController *objWeatherViewController = [[WeatherViewController alloc] initWithNibName:@"WeatherViewController" bundle:nil];
        [self.navigationController pushViewController:objWeatherViewController animated:YES];
        [objWeatherViewController release];
    }
    else if(pintButtonTag == 8)
    {
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Miscellaneous" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Milage Calculator",@"Advertisements",@"Lottery", nil];
        actionSheet.tag = 3;
        actionSheet.delegate = self;
        actionSheet.actionSheetStyle =  UIActionSheetStyleBlackTranslucent;
        [actionSheet showInView:self.view];
        /*
         MilageTrackerViewController *objMilageTrackerViewController = [[MilageTrackerViewController alloc] initWithNibName:@"MilageTrackerViewController" bundle:nil];
         [self.navigationController pushViewController:objMilageTrackerViewController animated:YES];
         [objMilageTrackerViewController release];
         */
    }
    else if(pintButtonTag == 9)
    {
        MusicListViewController *objMusicListViewController = [[MusicListViewController alloc] initWithNibName:@"MusicListViewController" bundle:nil];
        [self.navigationController pushViewController:objMusicListViewController animated:YES];
        [objMusicListViewController  release];
    }
    else if(pintButtonTag == 10)
    {
        NewsViewController *objNewsViewController = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
        [self.navigationController pushViewController:objNewsViewController animated:YES];
        [objNewsViewController  release];
    }