1
我在程序中包含了UIActionSheet。它包含2個按鈕,分別表示A和B.當用戶單擊A按鈕時,它會轉到另一個視圖。在該視圖中,它包含3個文本字段。因此,在mainviewcontroller中,我將這些值分配給這些文本字段。我將粘貼下面的代碼: -無法將數據從一個視圖傳遞到另一個視圖iphone
在MainViewController.m
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex: (NSInteger)buttonIndex
{
AnotherViewController *A = [[AnotherViewController alloc] init];
if (buttonIndex == 1)
{
A.newtask = name;
A.newsubtask = sub1;
A.newduedate = dateName;
A.newtime = timeName;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UpdateViewController *viewController =[storyboard instantiateViewControllerWithIdentifier:@"update"];
[self presentViewController:viewController animated:YES completion:NULL];
}
}
而且在AnotherViewcontroller.m
- (void)viewDidLoad
{
task_update.text = newtask;
subtask_update.text =newsubtask;
duedate_update.text = newduedate;
time_update.text = newtime;
NSLog(@"The task is :%@",newtask);
[super viewDidLoad];
// Do any additional setup after loading the view.
}
的問題是我在newtask越來越空值。任何人都可以告訴我解決方案。 :(
:沒有靜止,我在newtask越來越空值.. :( – Div
請參閱另一個視圖控制器中的更新代碼appDelegate =(AppDele門*)[[UIApplication sharedApplication]委託];添加此行視圖確實加載 – iSanjay
:非常感謝你..我明白了.. :) – Div