FrameRoot.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // FrameRoot.m
  3. // iShop
  4. //
  5. // Created by Rui Zhang on 12/14/23.
  6. //
  7. #import "FrameRoot.h"
  8. @interface FrameRoot ()
  9. @end
  10. @implementation FrameRoot
  11. - (void)viewDidLoad {
  12. [super viewDidLoad];
  13. // Do any additional setup after loading the view.
  14. NSArray* tabjson =(NSArray*) [self dictionaryFileName:@"tab.json"];
  15. NSMutableArray* tab = [NSMutableArray new];
  16. for(int i=0;i<tabjson.count;i++)
  17. {
  18. NSDictionary* item = tabjson[i];
  19. UIViewController* vc = [[UIStoryboard storyboardWithName:@"Frame" bundle:nil] instantiateViewControllerWithIdentifier:item[@"Identifier"]];
  20. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
  21. [tab addObject:navi];
  22. // Class class =NSClassFromString(item[@"class"]);
  23. // [[class alloc] initWithNibName:@"" bundle:nil];
  24. }
  25. self.viewControllers = tab;
  26. }
  27. - (NSMutableDictionary *)dictionaryFileName:(NSString *)name {
  28. NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];
  29. NSData *data = [NSData dataWithContentsOfFile:path];
  30. NSMutableDictionary *ret = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
  31. return ret;
  32. }
  33. /*
  34. #pragma mark - Navigation
  35. // In a storyboard-based application, you will often want to do a little preparation before navigation
  36. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  37. // Get the new view controller using [segue destinationViewController].
  38. // Pass the selected object to the new view controller.
  39. }
  40. */
  41. @end