#import <UIKit/UIKit.h> @interface OutletsAndActionsViewController : UlViewController { //---declaring the outlet--- IBOutlet UITextField *txtName; } //---expose the outlet as a property--- @property (nonatomic, retain) UITextField *txtName; @end
In the .m file:
#import “OutletsAndActionsViewController.h” @implementation OutletsAndActionsViewController //---synthesize the property--- @synthesize txtName; - (void)dealloc { //---release the outlet--- [txtName release]; [super dealloc]; }
In the .h file:
#import <UIKit/UIKit.h>
@interface OutletsAndActionsViewController : UIViewController
{
//---declaring the outlet---
IBOutlet UITextField *txtName;
}
//---expose the outlet as a property---
@property (nonatomic, retain) UITextField *txtName;
//---declaring the action---
-(IBAction) btnClicked:(id) sender;
@end
@implementation OutletsAndActionsViewController -(IBAction) btnClicked:(id) sender { //---action implementation here--- }
Use the alert view when you simply want to notify the user when something happens. Use an action sheet when the user needs to make a selection, usually from a set of options.
//---create a Button view--- frame = CGRectMake(10, 70, 300, 50); UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = frame; [button setTitle:@“Click Me, Please!” forState:UIControlStateNormal]; button.backgroundColor = [UIColor clearColor]; button.tag = 2000; [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
3.140.238.141