OutletsAndActions
Hi,
Thanks for your great book, which I am enjoying a lot.
I would like your help on this.
I am working in the example OutletsAndActions. This App does not show any error when I run it, but when I click the App icon the Simulator gives me a black screen without any button or field. These are my .m and .h files:
//
// OutletsAndActionsViewController.m
// OutletsAndActions
//
// Created by Jose Espinel on 12/29/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "OutletsAndActionsViewController.h"
@implementation OutletsAndActionsViewController
//---synthesize the property---
@synthesize txtName;
//---display an alert view when the button is clicked---
-(IBAction) btnClicked:(id) sender {
NSString *str = [[NSString alloc]
initWithFormat:@"Hello!, %@", txtName.text];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hello!"
message:str
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alert show];
[str release];
[alert release];
}
- (void)dealloc {
//---release the outlet---
[txtName release];
[super dealloc];
}
@end
__________________________________________________ ______
//
// OutletsAndActionsViewController.h
// OutletsAndActions
//
// Created by Jose Espinel on 12/29/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface OutletsAndActionsViewController : UIViewController {
//---declaring the outlet---
IBOutlet UITextField *txtName;
}
//---expose the outlet as property---
@property (nonatomic, retain) UITextField *txtName;
//---declaring the action---
-(IBAction) btnClicked:(id) sender;
@end
|