UITabBarController
中是一个按钮“保存”。拜托,如何从
3 UIViewControllers
中获取数据?我需要来自所有
UITextFields
的数据,以及所有
UItabBarController
(在保存按钮的ibaction中)。我该怎么做?谢谢在故事板上我的tabbarcontroller的图片。 第一个ViewController具有class studentvc。该类有一个文本字段。在
studentvc.m中是此代码:
UITextFields
StudentNameTextfield与情节板中的字段相连。然后,我有一个塔巴尔的课程,班级名称为StudentTBC。在文件studenttbc.mi有此代码:
UIViewControllores
UITextFields
已编辑了3.4 15:20
我对我的申请做了一步。第一部分是我的故事板-UitabbarController和3UiviewControllers。我删除了导航控制器。在第二部分中,我再次做一个媒体。第三部分是保存函数的代码(代码可以编写TextField的内容)和TabBarController的ViewDidload代码(可以将代码设置为TextField的字符串)。最后一部分是运行应用程序(结果是在控制台-NULL字符串和清除文本字段中)。我还尝试打印以下内容:
UIViewControllers
它必须是三个?或者?因为我的结果是0 ..为什么? :/我的电影:
https://www.youtube.com/watch?v = j6p__e48lli&feature =youtu.be
已编号2.4 20:58 -------------------------------------------------------------------------------------------------------------------------
Hello。我尝试了所有选项,但是什么也没有用。因此,我做了一个新的简单应用程序,其中只有一个带有两个UiviewControllers和一名UitaiteViewController(由于导航栏)的UitabbarController。请下载该项目并自己尝试。仅运行,然后单击“ tabar”按钮,然后在uitabbarcontroller上。按下保存按钮时,它应显示uiviewscontrollers的数量和文本场的值。您能尝试告诉我怎么了吗?谢谢。这是项目:
https://www.dropbox.com/s/r4jlzadr2us00ad/tbc.zip
要访问文本字段之一,您可以在下面使用代码:您有我的控制器如何连接,现在我意识到您在
#import <UIKit/UIKit.h>
#import "CoreDataHelper.h"
@interface StudentVC : UIViewController <UITextFieldDelegate>
@property (strong, nonatomic) NSManagedObjectID *selectedStudentID;
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) IBOutlet UITextField *studentNameTextField;
@end
之后得到了- (void)viewDidLoad
{
if (debug == 1) {
NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));
}
[super viewDidLoad];
StudentVC *studentVC = [self.tabBarController.viewControllers objectAtIndex:0];
studentVC.studentNameTextField.text = @"asad";
}
- (IBAction)save:(id)sender {
if (debug == 1) {
NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));
}
StudentVC *studentVC = [self.tabBarController.viewControllers objectAtIndex:0];
NSString *string = studentVC.studentNameTextField.text;
NSLog(@"string:%@", string);
NSInteger countOfViews = [self.tabBarController.viewControllers count];
NSLog(@"count:%ld", (long)countOfViews);
请检查
UTLETS为
uitextfields,
也检查输出
NSLOG(@“ StudentVC Textfield -%@”,StudentVC.StudentNametextfield); save()
如果也是无效的,那么您的插座肯定存在问题。