我不确定为什么这段代码不起作用。当我单击一个按钮(操作:buttonclick)时,它应该将两个文本框(MyTextLabel 和 MyTextLabel2)的文本增量值“r”加一。这是代码:
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MainView : UIView {
IBOutlet UIButton *MyButton;
IBOutlet UILabel *MyTextLabel;
IBOutlet UILabel *MyTextLabel2;
}
@property (nonatomic, retain) UIButton *MyButton;
@property (nonatomic, retain) UILabel *MyTextLabel;
@property (nonatomic, retain) UILabel *MyTextLabel2;
- (IBAction)buttonclick;
@end
主视图.m:
#import "MainView.h"
#include <stdlib.h>
#include <libc.h>
@implementation MainView
@synthesize MyButton, MyTextLabel, MyTextLabel2;
int r;
- (IBAction)buttonclick {
r++
if(r < 50) {
MyTextLabel.text = @"< 50";
}
else {
MyTextLabel2.text = @"=> 50";
}
}
@end