bla*_*uma 8 xcode push objective-c storyboard uiviewcontroller
我正在尝试从我的UIViewController切换回我的UITableViewController,但是它显然不按照我想要的方式工作.我从一开始就用故事板创建了我的界面,所以我并没有真正通过代码从一个视图移动到另一个视图.到目前为止,我只是通过故事板轻松实现了每个sergues的观点.但是当我尝试回到之前的视图时,将实现一个新的ViewController,因此我存储在旧视图中的所有数据都"丢失"了.
实际上我没有代码可以呈现给你(因为系列),但情况是:
- >我在UITableView中有一个MutableArray存储东西.
- >用户点击扫描按钮,扫描应在我的阵列中导入的新项目.
- >当试图回到我的tableView时,有一个新的控制器让我感到困惑,不知道我存储在旧的数据中.
那么我该如何简单地回到我的旧控制器,以防止一直创建一个新的控制器?
sergue-push是否总是会创建一个新的Controller?
(问题可能很简单,但我是新手.尝试搜索功能提供的一些结果,但没有一个工作:()
/ edit:Popback问题已经解决但阵列填充问题仍然存在.码:
GeneralSettings *sharedGS = [GeneralSettings sharedInstance];
sharedGS.strEAN = [[NSString alloc] initWithString:strCheckString];
[sharedGS.listArray insertObject:strCheckString atIndex:0];
NSLog(@"Anzahl der EAN-Codes: %d\nErster Code: %@\n In Variable: %@", sharedGS.listArray.count, [sharedGS.listArray objectAtIndex:0],sharedGS.strEAN);
Run Code Online (Sandbox Code Playgroud)
sharedGS.strEAN中的数据("83274572354"ie)listArray中的数据(null)
T.J*_*.J. 20
你不要推迟.这将创建前一个控制器类的新实例.你回来了.你可以完成这两种方式.
1:在您希望返回(弹出)平板电脑视图控制器时,在以下语句中放入代码.
[self.navigationController popViewControllerAnimated:YES];
2:如果要在storyboard中执行此操作,则需要实现以下自定义segue类:
履行
// PopSegue.m
#import "PopSegue.h"
@implementation PopSegue
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
[src.navigationController popViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
和标题
// PopSegue.h
#import <UIKit/UIKit.h>
@interface PopSegue : UIStoryboardSegue
@end
Run Code Online (Sandbox Code Playgroud)
将此方法放在UIViewController中,将属性设置回UITableViewController:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"goBackToTableView"]) {
[[segue destinationViewController] set{whatEverProperyYouWantTo}: {valueOfPropertyToSet}];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22552 次 |
| 最近记录: |