iphone - 三个else-if语句

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center。




7年前关闭。




嗨,我尝试有4个按钮,并且每个按钮在按下时都有不同的警报。我遇到了一个问题,我有3个按钮,因此我决定添加一个“为我的应用评分”按钮,但是现在无法正常工作,请帮帮我。 (通过错误表示扩展)(组织=组织(在应用程序中固定),电子邮件-应用程序中的真实电子邮件,
#define TAG_Band 1
#define TAG_DEV 2
#define TAG_EDEV 3
#define TAG_RATE 4

@interface Org.ContactInfo () <MFMailComposeViewControllerDelegate>

@end

@implementation Org.ContactInfo:UIViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"Contacts";

    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(IBAction)ContactBand:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact the Band" message:@"Contact the Org. or go to their website!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Visit the Org. Website",@"E-Mail The Org. President", @"E-Mail The Org. Treasurer",  nil];
    alert.tag = TAG_Band;
    [alert show];
}
-(IBAction)ContactDev:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact Me" message:@"Contact Me on Features you would like me to consider! I will do my Best to look at all of the Suggestions!" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Visit My Website",@"E-Mail Me!",  nil];
    alert.tag = TAG_DEV;
    [alert show];
}
-(IBAction)RateMyApp:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate My App" message:@"When Your Reviewing my App, Please remember that this app was at no cost to the Mighty Mustang Band." delegate:self cancelButtonTitle:@"Not Right Now" otherButtonTitles:@"Rate My App!!",  nil];
    alert.tag = TAG_RATE;
    [alert show];


}
-(IBAction)AppInfo:(id)sender;{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Version 1.0" message:@"More Updates Coming Soon. Please Feel Free to E-Mail me on features that you would like me to consider" delegate:self cancelButtonTitle:@"Not Right Now" otherButtonTitles:@"Email-Me",  nil];
    alert.tag = TAG_EDEV;
    [alert show];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == TAG_Band){


        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://URL.org"]];

        }
        else if (buttonIndex==2){
            //Subject
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"Org. President";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Person@Org.org"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
        else if (buttonIndex==3){
            //Subject
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"Org. Treasurer, ";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Person@Org.org"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_DEV){
        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://stepheniosdeveloper.wordpress.com"]];

        }
        else if (buttonIndex==2){
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Email@gmail.com"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_EDEV);{
        if (buttonIndex==1){
            NSString *emailTitle = @"";
            //Recipients
            NSString *emailBody=@"";
            NSArray *toRecipients = [NSArray arrayWithObject:@"Email@gmail.com"];

            MFMailComposeViewController *mc=[[MFMailComposeViewController alloc] init];
            mc.mailComposeDelegate = self;
            [mc setSubject:emailTitle];
            [mc setSubject:emailBody];
            [mc setToRecipients:toRecipients];

            [self presentViewController:mc animated:YES completion:NULL];

        }
    }
    else if (alertView.tag == TAG_RATE);{         //Expected Expression
        if (buttonIndex==1){
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/Org/id607257427?ls=1&mt=8"]];
        }
    }
}

在我在(TAG_RATE)上添加了最后一个之前,它已经起作用了,但是现在我不明白为什么它不再起作用了。请帮忙。

最佳答案

您的代码中有一个错别字:在最后两个;条件之后,您还有多余的else if:

    else if (alertView.tag == TAG_EDEV)/*;*/{  // extra `;`
            //...
    }
    else if (alertView.tag == TAG_RATE)/*;*/{   // extra `;`       //Expected Expression
            // ...
    }

https://stackoverflow.com/questions/15046784/

上一篇:c++ - 配置软件时出错

下一篇:c++ - 在 ‘begin’中请求成员 ‘c’,它是非类类型 ‘char [101]’ sort(c.begin(),c.end());

相关文章:

iphone - xcode 中 uitextfield 的高度是多少(iphone)

objective-c - NSImageView 中的图像和按钮位置错误

iphone - 如何同时检测主视图 UILongPressGestureRecognizer 和 subview UIPanGestureRecognizer

iphone - 使用 UIView 作为容器

ios - 为标识符(单元格)注册的无效 Nib

ios - 定义ivar的最佳方式是什么?

swift - 调用中参数 'completion' 缺少参数

C: 为什么我会收到编译错误“"dereferencing pointer to incomplete type ‘struct xy’”?

java - 无法静态引用非静态方法

iphone - UItbaleview Cell json 内容未在 iOS 中显示

相关文章:

c++ - 配置软件时出错

c++ - C++错误,编译器无法识别字符串::push_back [closed]

c++ - g++,如何找到出错的地方?

c++ - C++基本内容。什么东西少了???不可能那么明显

c++ - 声明和初始化struct类型变量时出错

c++ - ISO C++禁止在结构内初始化成员

java - Java “try without catch”和 “catch without tr

java - 为什么我的代码会导致编译器错误?

compiler-errors - Vaadin 按钮单击监听器错误

c++ - 为什么我看到 “member function with the same name a