1,105,331 Community Members

UIAlertView Button Actions

Member Avatar
NetJunkie
Junior Poster
162 posts since Aug 2011
Reputation Points: 29 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 0 [?]
 
0
 

So, I am having some trouble getting my alertView to actually perform an action on a certain button click. Here is the code I have so far and I hope someone can help me debug this issue and get this working! Thanks in advanced!

ViewController.h

//
//  ViewController.h
//  IMWT360
//
//  Created by Chris Harris on 1/22/13.
//  Copyright (c) 2013 InModWeTrust360. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface ViewController : UIViewController <ADBannerViewDelegate>

@property (nonatomic, retain) IBOutlet ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;

- (IBAction)myVideos:(id)sender;
- (IBAction)myFacebook:(id)sender;
- (IBAction)myTwitter:(id)sender;
- (IBAction)myInstagram:(id)sender;
- (IBAction)myWebsite:(id)sender;
- (IBAction)myAbout:(id)sender;
- (IBAction)myReport:(id)sender;
- (IBAction)myInfoButton:(id)sender;
- (IBAction)myPurcahseButton:(id)sender;

@end

ViewController.m

//
//  ViewController.m
//  IMWT360
//
//  Created by Chris Harris on 1/22/13.
//  Copyright (c) 2013 InModWeTrust360. All rights reserved.
//

#import "ViewController.h"
#import "myVideos.h"
#import "faceBook.h"
#import "twitter.h"
#import "instaGram.h"
#import "webSite.h"
#import "about.h"

#define PURCHASE 1
#define INFO 2

@interface ViewController ()

@end

@implementation ViewController
@synthesize aBanner,bannerIsVisible;

- (void)viewDidLoad
{
    [super viewDidLoad];
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOn" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible)
    {
        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];
        banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
        [UIView commitAnimations];
        self.bannerIsVisible = NO;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)myVideos:(id)sender
{
    myVideos *second = [[myVideos alloc] initWithNibName:@"myVideos" bundle:nil];
    [self presentViewController:second animated:YES completion:nil];
}

- (IBAction)myFacebook:(id)sender
{
    faceBook *third = [[faceBook alloc] initWithNibName:@"faceBook" bundle:nil];
    [self presentViewController:third animated:YES completion:nil];
}

- (IBAction)myTwitter:(id)sender
{
    twitter *fourth = [[twitter alloc] initWithNibName:@"twitter" bundle:nil];
    [self presentViewController:fourth animated:YES completion:nil];
}

- (IBAction)myInstagram:(id)sender
{
    instaGram *fifth = [[instaGram alloc] initWithNibName:@"instaGram" bundle:nil];
    [self presentViewController:fifth animated:YES completion:nil];
}

- (IBAction)myWebsite:(id)sender
{
    webSite *sixth = [[webSite alloc] initWithNibName:@"webSite" bundle:nil];
    [self presentViewController:sixth animated:YES completion:nil];
}

- (IBAction)myAbout:(id)sender
{
    about *seventh = [[about alloc] initWithNibName:@"about" bundle:nil];
    [self presentViewController:seventh animated:YES completion:nil];
}

- (IBAction)myReport:(id)sender
{

}

- (IBAction)myInfoButton:(id)sender
{
    UIAlertView *alertView; alertView = [[UIAlertView alloc]
    initWithTitle:@"IMWT360 Mobile"
    message:@"Send Bugs, Feedback, and Suggestions to:\ninmodwetrust360@gmail.com"
    delegate:nil
    cancelButtonTitle:@"OK"
    otherButtonTitles:nil, nil];
    alertView.tag = INFO;
    [alertView show];
}

- (IBAction)myPurcahseButton:(id)sender
{
    UIAlertView *alertView; alertView = [[UIAlertView alloc]
    initWithTitle:@"Purchase IMWT360 Mobile"
    message:@"Purchase IMWT360 Mobile to:\nRemove Ads\nUnlock Live Chat"
    delegate:nil
    cancelButtonTitle:@"No Thanks"
    otherButtonTitles:@"Buy App", nil];
    alertView.tag = PURCHASE;
    [alertView show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag = PURCHASE && buttonIndex == 1)
    {
        instaGram *fifth = [[instaGram alloc] initWithNibName:@"instaGram" bundle:nil];
        [self presentViewController:fifth animated:YES completion:nil];
    }
}

@end

Thanks again!

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: