Loopback.io匿名模型定义(Loopback.io anonymous model definitions)
是否可以使用slc工具定义匿名模型,或者在json中手动定义? 例如,我有一个特定的模型成员,并希望有一个可重复使用的匿名“地址”模型,但在后端存储中没有,但直接添加到文档中。 Mongoose提供与此类似的功能,没有建模模式。 如果这是可能的,我将在member.json文件中定义它。
{ "name": "member", "base": "PersistedModel", "properties": { "fullname": { "type": "string", "required": "true", "length": "64", "doc": "User's full name" }, "displayname": { "type": "string", "required": "true", "length": "64", "doc": "User's display name" }, "address": { "type": [ "Address" ], "required": true } }, "validations": [], "relations": {}, "acls": [], "methods": [] }
Is it possible to define anonymous models using the slc tools, or manually in json? For example I have a particular model member and want to have a reusable anonymous 'address' model, but not have that in a backend store, but added directly to the document. Mongoose provides functionality similar to this with no modeled schemas. If this is possible, where in the member.json file would I define this.
{ "name": "member", "base": "PersistedModel", "properties": { "fullname": { "type": "string", "required": "true", "length": "64", "doc": "User's full name" }, "displayname": { "type": "string", "required": "true", "length": "64", "doc": "User's display name" }, "address": { "type": [ "Address" ], "required": true } }, "validations": [], "relations": {}, "acls": [], "methods": [] }
原文:https://stackoverflow.com/questions/26104546
最满意答案
您好纳粹我刚刚找到解决方案从http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/
你可以这样做: -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch. self.splitViewController =[[UISplitViewController alloc]init]; self.rootViewController=[[RootViewController alloc]init]; self.detailViewController=[[FirstDetailViewController alloc]init]; UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController]; UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController]; self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil]; self.splitViewController.delegate=self.detailViewController; // Add the split view controller's view to the window and display. [window addSubview:self.splitViewController.view]; [window makeKeyAndVisible]; return YES; } -(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { /* When a row is selected, set the detail view controller's detail item to the item associated with the selected row. */ NSUInteger row = indexPath.row; [self.appDelegate.splitViewController viewWillDisappear:YES]; NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]]; [viewControllerArray removeLastObject]; if (row == 0) { self.firstDetailViewController=[[[FirstDetailViewController alloc] init]autorelease]; [viewControllerArray addObject:self.firstDetailViewController]; self.appDelegate.splitViewController.delegate = self.firstDetailViewController; } if (row == 1) { self.secondDetailViewController=[[[SecondDetailViewController alloc]init]autorelease]; [viewControllerArray addObject:self.secondDetailViewController]; self.appDelegate.splitViewController.delegate = self.secondDetailViewController; } [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO]; [self.appDelegate.splitViewController viewWillAppear:YES]; [viewControllerArray release]; }
你也可以查看这个演示http://kshitizghimire.com.np/wp-content/uploads/2011/01/MultipleDetailViewsWithNavigator.zip
hi Nazia i just found solution From http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/
you can do like:-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch. self.splitViewController =[[UISplitViewController alloc]init]; self.rootViewController=[[RootViewController alloc]init]; self.detailViewController=[[FirstDetailViewController alloc]init]; UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController]; UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController]; self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil]; self.splitViewController.delegate=self.detailViewController; // Add the split view controller's view to the window and display. [window addSubview:self.splitViewController.view]; [window makeKeyAndVisible]; return YES; } -(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { /* When a row is selected, set the detail view controller's detail item to the item associated with the selected row. */ NSUInteger row = indexPath.row; [self.appDelegate.splitViewController viewWillDisappear:YES]; NSMutableArray *viewControllerArray=[[NSMutableArray alloc] initWithArray:[[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] viewControllers]]; [viewControllerArray removeLastObject]; if (row == 0) { self.firstDetailViewController=[[[FirstDetailViewController alloc] init]autorelease]; [viewControllerArray addObject:self.firstDetailViewController]; self.appDelegate.splitViewController.delegate = self.firstDetailViewController; } if (row == 1) { self.secondDetailViewController=[[[SecondDetailViewController alloc]init]autorelease]; [viewControllerArray addObject:self.secondDetailViewController]; self.appDelegate.splitViewController.delegate = self.secondDetailViewController; } [[self.appDelegate.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO]; [self.appDelegate.splitViewController viewWillAppear:YES]; [viewControllerArray release]; }
you can also check this Demo http://kshitizghimire.com.np/wp-content/uploads/2011/01/MultipleDetailViewsWithNavigator.zip
相关问答
更多-
我找到了一个解决方案,诀窍是删除segue并使用这样的故事板引用: 出于测试和教学目的,我创建了一个完整的测试项目, 可从GitHub获得 。 这演示了使用多个故事板进行详细视图。 11月28日更新:此解决方案有效,但需要iOS 9.完全可以使用另一个UIViewController作为DetailViewController(意味着可以使用模板),只要你删除segue,实现tableView: didSelectRowAtIndexPath并使用示例中的代码。 在后一种情况下,它也适用于iOS 8。 I ...
-
我会使用通知,所以在你的主人: -(void) viewDidLoad { ... [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(someMethod) name:@"DoSomeMethod" object:nil]; } -(void) someMethod { ... } 并在您的细节: - (void) tableView:(UITableView *)table ...
-
我解决了以编程方式删除和添加视图。 [self.segmentButtonBgView removeFromSuperview]; [self.segmentButtonBgView setTranslatesAutoresizingMaskIntoConstraints:YES]; [self.segmentButtonBgView setFrame:CGRectMake(self.segmentButtonBgView.frame.origin.x-158, self.segmentButtonBgVi ...
-
带有多个Detail View Controller的UISplitViewController(UISplitViewController with multiple Detail View Controller)[2022-11-25]
您好纳粹我刚刚找到解决方案从http://kshitizghimire.com.np/uisplitviewcontroller-multipledetailviews-with-navigation-controller/ 你可以这样做: - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override p ... -
UISplitViewController详细信息视图不在旋转时调整大小(UISplitViewController Detail View not Resizing on rotation)[2022-08-24]
与splitViewController方法类似,您应转发以下调用: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; // Forward to detail view controller here: } 到不可见 ... -
如果赛段已经存在,那么尝试从主视图中移除赛段到其他细部视图,并使用细节赛格重新创建它们。 If the segues were already there then try removing the segues from the master view to the other detail views and recreating them using a detail segue.
-
你不应该试着这样做: 拆分视图控制器必须始终是您创建的任何接口的根。 换句话说,您必须始终从UISplitViewController对象安装视图作为应用程序窗口的根视图。 你可以在这里阅读更多相关信息 You should not try to do that: A split view controller must always be the root of any interface you create. In other words, you must always install the vi ...
-
我认为有两件事可能是问题所在。 您应该包含其余代码。 特别是当用户在主服务器中执行操作时更改详细信息视图控制器的部分。 如果你只是实例化detailNavController那么visibleViewController可能是nil。 即使你设置它的根,也没有“可见”的视图控制器,因为它实际上还没有显示。 您可能想尝试使用topViewController 我不确定你是在每次用户选择master中的东西时创建一个新的detailNavController ,但如果你是,你需要再次将rootPopoverBu ...
-
在我的项目中导致这种导航特性的罪魁祸首是我从SO用户下载的扩展名为UIViewController+BackButtonHandler 。 这个处理程序拦截导航后退按钮,这样当用户按下时我就有机会做额外的工作。 此类别扩展代码会覆盖navigationBar:shouldPopItem:导致默认导航中断。 我不知道这个代码是在执行,因为我没有使用它,而只是在我的项目中加入。 哇...我的头撞在墙上2天。 The culprit causing this navigation peculiarity in m ...
-
UISplitViewController详细信息视图中的静态单元格表(Table with static cells in UISplitViewController detail view)[2022-11-29]
该错误意味着为了使用静态单元格,您必须拥有UITableViewController 。 使用UIViewController并向其添加UITableView是不够的。 我要做的是为我的细节添加一个container view ,并在其中嵌入一个UITableViewController (ctrl + drag-embed segue),这样UITableViewController成为你的细节VC的childViewController ,你可以在点击不同的单元格时更改它在主人。 如果您不想更改它,则只 ...