Can't seem to get my UIButton to hide or change coordinates
The basic premise of my app is that when it loads it hides the button "findMe" and then when the button "go" is selected it shows the button and sets it to a specific coordinate (Once I fix this issue I am going to implement random coordinates). The problem is my button does not hide when the app loads and the "go" button does not change the coordinates. I created the button in interface builder. I am not sure why this is not working as this seems like such an easy task. Any help at where I went wrong is greatly appreciated. Thanks.
.h file
#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 file
#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];
}
Ensure that the outlets and actions are hooked up in Interface Builder. The buttons should be attached to the file owner as Referencing Outlets, and the actions should be hooked up to the Touch Up Inside event.
精彩评论