-1
我正在申請爲我有兩個頁面:如何將測試值從一個視圖傳遞到其他視圖?
第1頁
在我所1個文本框,一個提交按鈕。
當用戶在文本字段中輸入值時,輸入到文本文件中的值應顯示在下一頁上。
第2頁有 1文本框顯示的數值,在第一頁中輸入和編輯按鈕,編輯文本,如果他想的
,如果他在編輯按鈕,點擊他應該移動到一個頁面,是他可以看到,他已經進入了價值,應改變
我能夠從一個頁面傳遞文本字段值等,但不能顯示在一個頁面上相同的值當用戶單擊編輯按鈕..
以下是我的page1.h文件
#import <UIKit/UIKit.h>
#import "new.h"
@interface tryViewController : UIViewController {
IBOutlet UITextField *textField;
}
@property(nonatomic,retain)IBOutlet UITextField *textField;
-(IBAction)submit;
@end
以下是我的第1頁.m文件:
#import "tryViewController.h"
@implementation tryViewController
@synthesize textField;
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[theTextField resignFirstResponder];
return YES;
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
-(IBAction)submit
{
new *pg = [new alloc];
pg.str = textField.text;
[self .view addSubview:pg.view];
[self presentModalViewController:pg animated:YES];
}
@end
以下是我的第2頁.h文件中:
#import <UIKit/UIKit.h>
#import "tryViewController.h"
@interface new : UIViewController {
IBOutlet UITextField *txtField;
NSString *str;
}
@property(nonatomic,retain)IBOutlet UITextField *txtField;
@property(nonatomic,retain)NSString *str;
-(IBAction)back;
@end
following is my page2 .m file:
#import "new.h"
@implementation new
@synthesize str;
- (void)viewDidLoad {
txtField.text = str;
[super viewDidLoad];
}
- (void)dealloc {
[super dealloc];
}
-(IBAction)back
{
}
@end
好的,我會試試....謝謝 – Nilesh
謝謝mr.Mathieu Hausherr .....工作的 – Nilesh
謝謝mr.mathieu – 2013-04-09 10:18:12