Xcode でアプリを作成しています。ボタンを 100 回クリックしたときにアラート ビューを表示したいのですが、何らかの理由でボタンを 100 回クリックしても何も起こりません。アプリにあるすべてのコードを表示します。現時点で、私がxibで行ったことと、皆さんが助けてくれることを願っています。
#import <UIKit/UIKit.h>
int counter;
@interface ViewController : UIViewController {
IBOutlet UILabel *count;
}
-(IBAction)plus;
-(IBAction)minus;
-(IBAction)zero;
@end
実装
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void) buttonAction {
counter++;
if(counter == 100)
[self showAlert];
}
- (void) showAlert {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Tile"
message:@"This is the message"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
}
-(IBAction)plus {
counter=counter + 1;
count.text = [NSString stringWithFormat:@"%i",counter];
}
-(IBAction)minus {
counter=counter - 1;
count.text = [NSString stringWithFormat:@"%i",counter];
}
-(IBAction)zero {
counter=0;
count.text = [NSString stringWithFormat:@"%i",counter];
}
- (void)viewDidLoad {
counter=0;
count.text = @"0";
[super viewDidLoad];
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
それが私が持っているすべてのコードであり、私が得ている問題は、カウンターが正常に動作することです.100に達したときに何も起こりません.
そして警告なし