- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试在标签栏中的 View 之间传递一些数据。我的第一个 View 能够从我的模型类加载数据并对其进行操作。但是当我点击标签栏 Controller 中的第二个或第三个标签时,数据没有被传递。这是我试图通过它的方式。
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (tabBarController.selectedIndex == 1){
HashTagTableViewController *hash [[HashTagTableViewController alloc]init];
hash.userArray = feed.userArray;
}else if (tabBarController.selectedIndex == 2){
PhotoTagTableViewController *photo = [[PhotoTagTableViewController alloc]init;
photo.userArray = feed.userArray;
}
}
feed 是我在当前 View Controller 中创建的模型类实例的名称。我试图避免创建模型类的多个实例,因为它必须对 API 进行多次调用。我要做的就是将 feed.userArray
传递给不同的 View 以进行不同的操作。
最佳答案
不要在这个方法中创建 View Controller 。UITabBarController 在初始化时自动创建所有 View Controller 。试试这个:
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (tabBarController.selectedIndex == 1){
HashTagTableViewController *hash = (HashTagTableViewController *) viewController;
hash.userArray = feed.userArray;
}else if (tabBarController.selectedIndex == 2){
PhotoTagTableViewController *photo = (PhotoTagTableViewController *)viewController;
photo.userArray = feed.userArray;
}
}
关于ios - 试图在标签栏 Controller 之间传递数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31043596/
我是 C++ 的新手,我在使用这段代码时遇到了问题: string output_date(int day, int month, int year){ string date; if
所以我这样做了 tar cvzf test.zip FP 为了创建目录 FP 的 zip 但是,它会列出 zip 中的目录 FP/ FP/php/ FP/php/pdf/ FP/php/docs/ F
我正在尝试在 Swift、Xcode 7.3(所以是 Swift 2.2)中创建一个通用类,但我似乎无法让它通过编译器: protocol Struct1Protocol { } struct Str
我的测试用例是这样的: class FooTest extends PHPUnit_Framework_TestCase { /** @covers MyClass::bar */ f
我正在尝试将brew install wine作为使electron-builder工作的一步。但是我所能得到的只是以下响应: ==> Installing dependencies for wine
我这样做: string[,] string1 = {{"one", "0"},{"Two", "5"},{"Three","1"}}; int b = 0; for(int i = 0; i <=
我正在尝试使用 SetWindowsHookEx 键盘 Hook Notepad.exe。 如您所见,工作线程正在将其 ASCII 代码(即 wParam)发送到指定的服务器。 UINT WINAPI
我正在尝试将 ListView 实现到我的 Fragment 中,但无论我尝试什么,我都会得到一个 NullPointerException。我检查对象是否为 null 并记录是否为 null,看起来
我尝试在一行中对齐两个 div。使用 float left 属性,一切顺利。但是当我在 div 中使用图像时,它开始产生问题。 所以这是我的示例代码:- Some headi
我目前正在使用此代码来获取图像的灰度图像表示并以 (512, 370, 1) 的格式表示它大批。 img_instance = cv2.imread(df.iloc[i][x_col]) / 255.
总结 我正在创建一个简单的应用程序,它允许用户选择一个包含顶级窗口的进程。用户首先键入 native DLL(而非托管 DLL)的路径。然后用户键入将在 Hook 过程中调用的方法的名称。该方法不得返
我是一名优秀的程序员,十分优秀!