我在我的程序中包含了 UIActionSheet。它包含 2 个按钮,比如 A 和 B。当用户单击 A 按钮时,它会转到另一个视图。在该视图中,它包含 3 个文本字段。所以在主视图控制器中,我将值分配给这些文本字段。我将粘贴下面的代码:-
在 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];
}
}
而在另一个视图控制器.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.
}
问题是我在新任务中得到了空值。谁能告诉我解决方案。:(