アプリ委任ファイル:
// Create instance of UINavigationController
UINavigationController *myNavigationController;
// Create initialized instance of UITabBarController
UITabBarController *tabBarController = [[UITabBarController alloc] init];
// Create initialized instance of NSMutableArray to hold our UINavigationControllers
NSMutableArray *tabs = [[NSMutableArray alloc] init];
// Create first UIViewController
UIViewController *myFirstViewController = [[UIViewController alloc] init];
[myFirstViewController setTitle:@"First"];
// Initialize the UINavigationController
myNavigationController = [[UINavigationController alloc] initWithRootViewController:myFirstViewController];
// Add UINavigationController to you tabs
[tabs addObject:myNavigationController];
// Release UIViewController and UINavigationController
[myFirstViewController release], [myNavigationController release];
// Create second UIViewController
UIViewController *mySecondViewController = [[UIViewController alloc] init];
[mySecondViewController setTitle:@"Second"];
// Initialize the UINavigationController
myNavigationController = [[UINavigationController alloc] initWithRootViewController:mySecondViewController];
// Add UINavigationController to you tabs
[tabs addObject:myNavigationController];
// Release UIViewController and UINavigationController
[mySecondViewController release], [myNavigationController release];
// Add the tabs to the UITabBarController
[tabBarController setViewControllers:tabs];
// Add the view of the UITabBarController to the window
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
ViewController.h ファイル:
UITextField *textfld;
viewDidLoad メソッド:
textfld = [[UITextField alloc] initWithFrame:<Frame>];
textfld.delegate = self;
[textfld becameFirstResponder];
を使用して.hファイルのテキストフィールドデリゲートを作成します
@interface YourClassName:UIViewController <UITextFieldDelegate>.
それがうまくいくことを願っています。