Hello,
I am trying to develop an app where a user will be able enter text using the virtual keyboard and then have that data displayed on a label.
I am looking to have the following sequence: The user will access the text field, type a string of characters using the virtual keyboard, and the string of characters will be displayed on a label.
I have the following books "Programming in Objective C 2.0" by Stephen Kochan and "Beginning iOS4 Application Development" by Wei-Meng Lee.
Stephen Kochan's book goes through an exercise where a calculator app is developed. In this app a button for each calculator number corresponds with a label. I have been able to do the beginning parts of this app successfully. I believe I can use this app a stepping point and would like to modify its code for my needs.
To summarize currently I can know how take a preprogrammed string and attach it to a label but how do I allow that string to be entered in by a user using a text field?
Thanks.
The code for the I am using as my base is as follows:
I am trying to develop an app where a user will be able enter text using the virtual keyboard and then have that data displayed on a label.
I am looking to have the following sequence: The user will access the text field, type a string of characters using the virtual keyboard, and the string of characters will be displayed on a label.
I have the following books "Programming in Objective C 2.0" by Stephen Kochan and "Beginning iOS4 Application Development" by Wei-Meng Lee.
Stephen Kochan's book goes through an exercise where a calculator app is developed. In this app a button for each calculator number corresponds with a label. I have been able to do the beginning parts of this app successfully. I believe I can use this app a stepping point and would like to modify its code for my needs.
To summarize currently I can know how take a preprogrammed string and attach it to a label but how do I allow that string to be entered in by a user using a text field?
Thanks.
The code for the I am using as my base is as follows:
Code:
[B]AppDelegate.h file[/B]
#import <UIKit/UIKit.h>
@interface iPhone_1AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UILabel *display;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UILabel *display;
- (IBAction) click1: (id) sender;
@end
[B]AppDelegate.m[/B]
#import "iPhone_1AppDelegate.h"
@implementation iPhone_1AppDelegate
@synthesize window, display;
- (void) applicationDidFinishLaunching:(UIApplication *)application {
//overide point for customization after application launch
[window makeKeyAndVisible];
}
-(IBAction) click1: (id) sender
{
[display setText: @"1"];
}
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
Last edited by a moderator: