3
我的應用程序的基本前提是,當它加載時隱藏按鈕「findMe」,然後當選擇按鈕「go」時,它顯示按鈕並設置它到一個特定的座標(一旦我解決了這個問題,我將實現隨機座標)。問題是我的按鈕不會在應用程序加載時隱藏,而「去」按鈕不會更改座標。我在界面構建器中創建了按鈕。我不知道爲什麼這不起作用,因爲這似乎是一件容易的事情。任何幫助我出錯的地方都非常感謝。謝謝。似乎無法讓我的UIButton隱藏或更改座標
.h文件中
#import <UIKit/UIKit.h>
@interface Senior_DesignViewController : UIViewController
<UIAlertViewDelegate> {
IBOutlet UIButton *findMe;
IBOutlet UIButton *go;
IBOutlet UILabel *success;
}
@property (retain, nonatomic) UIButton *findMe;
@property (retain, nonatomic) UILabel *success;
@property (retain, nonatomic) UIButton *go;
-(IBAction)foundMe:(id)sender;
-(IBAction)go:(id)sender;
@end
.m文件
#import "Senior_DesignViewController.h"
@implementation Senior_DesignViewController
@synthesize findMe;
@synthesize success;
@synthesize go;
-(IBAction)foundMe:(id)sender {
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:@"Congratulations"
message:@"You have found the box"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertDialog show];
[alertDialog release];
}
-(IBAction)go:(id)sender {
findMe.frame = CGRectMake(100, 100, 50, 50);
findMe.hidden = NO;
}
- (void)viewDidLoad {
findMe.hidden = YES;
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:@"Welcome to our SNR DSN App"
message:@"Please Calibrate NOW!"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertDialog show];
[alertDialog release];
[super viewDidLoad];
}
您是否已將IBOutlet成員關聯到IB中的按鈕? – SVD 2011-03-24 21:57:05
該死的工作。這很簡單,我感到很蠢。應該有雙重檢查那個錯誤。如果IBActions照顧。謝謝一堆。 – tguidon 2011-03-24 22:00:13
不要覺得愚蠢,直到它發生*秒*時間':)' – 2011-03-24 22:01:32