ios - 不能在 Storyboard之间继续

标签 ios objective-c segue

所以我找到了一个很好的大纲,可以满足我的需求。但是,我不能切换到其他 Storyboard吗?

如何使用“内置”窗口进入其他 Storyboard?

包括我的 ViewController.M 实现文件。这段代码似乎自己制作了一个表格,而不是使用 Storyboard(导航 Controller )...

如何让它继续到其他 Storyboard?

   #import "ViewController.h"        

        @interface ViewController ()

        @end

        #define getDataURL @"http://??.??.??.??/phpfile12.php"

        @implementation ViewController
        @synthesize json, storesArray, myTableView;
        - (void)viewDidLoad
        {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.




    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};


    [self.navigationController.navigationBar setBackgroundImage:[UIImage new]
                                                  forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    self.navigationController.navigationBar.translucent = YES;
    self.navigationController.view.backgroundColor = [UIColor clearColor];

    //set the title
    self.title = @"";

    [self retrieveData];
        }


        - (void)didReceiveMemoryWarning
        {
            [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
        }

        #pragma mark - UITableView Datasource

        - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
        }

        - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return storesArray.count;
        }

        - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:        (NSIndexPath *)indexPath {
            static NSString *cellIdentifier = @"Cell";

            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

            if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    }

    //cell.textLabel.text = [NSString stringWithFormat:@"Cell %d", indexPath.row];

    //Retrieve the current city object for use with this indexPath.row
    Store * currentStore = [storesArray objectAtIndex:indexPath.row];

    cell.textLabel.text = currentStore.storeName;
    cell.detailTextLabel.text = currentStore.storeAddress;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
        }

        #pragma mark - UITableView Delegate methods

        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
        {
            DetailViewController * dvc = [[DetailViewController alloc]init];

    //Retrieve the current selected city
    Store * currentStore = [storesArray objectAtIndex:indexPath.row];
    dvc.name = currentStore.storeName;
    dvc.address = currentStore.storeAddress;
    dvc.startDate = currentStore.storeStartDate;
    dvc.endDate = currentStore.storeEndDate;
    dvc.startTime = currentStore.storeStartTime;
    dvc.endTime = currentStore.storeEndTime;
    dvc.totalSales = currentStore.storeTotalSales;
    dvc.voids = currentStore.storeVoids;
    dvc.discounts = currentStore.storeDiscounts;
    dvc.guestCount = currentStore.storeGuestCount;
    dvc.peopleServed = currentStore.storePeopleServed;
    dvc.employeeClockIn = currentStore.storeEmployeeClockIn;


    [self.navigationController pushViewController:dvc animated:YES];
        }


        #pragma mark - Methods
        - (void) retrieveData
        {
    NSURL * url = [NSURL URLWithString:getDataURL];
    NSData * data = [NSData dataWithContentsOfURL:url];

            json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];



            //Set up our cities array
            storesArray = [[NSMutableArray alloc]init];

            for (int i = 0; i < json.count; i++)
            {
                //Create city object
        NSString * sID = [[json objectAtIndex:i] objectForKey:@"id"];
        NSString * sAddress = [[json objectAtIndex:i] objectForKey:@"storeAddress"];
        NSString * sName = [[json objectAtIndex:i] objectForKey:@"storeName"];
        NSString * sStartDate = [[json objectAtIndex:i] objectForKey:@"storeStartDate"];
        NSString * sStartTime = [[json objectAtIndex:i] objectForKey:@"storeStartTime"];
        NSString * sEndDate = [[json objectAtIndex:i] objectForKey:@"storeEndDate"];
        NSString * sEndTime = [[json objectAtIndex:i] objectForKey:@"storeEndTime"];
        NSString * sTotalSales = [[json objectAtIndex:i] objectForKey:@"storeTotalSales"];
        NSString * sVoids = [[json objectAtIndex:i] objectForKey:@"storeVoids"];
        NSString * sDiscounts = [[json objectAtIndex:i] objectForKey:@"storeDiscounts"];
        NSString * sGuestCount = [[json objectAtIndex:i] objectForKey:@"storeGuestCount"];
        NSString * sPeopleServed = [[json objectAtIndex:i] objectForKey:@"storePeopleServed"];
        NSString * sEmployeeClockIn = [[json objectAtIndex:i] objectForKey:@"storeClockIn"];




                Store * myStore = [[Store alloc]initWithStoreID: (NSString *) sID andStoreName: (NSString *) sName andStoreStartDate: (NSString *) sStartDate andStoreStartTime: (NSString *) sStartTime andStoreEndDate: (NSString *) sEndDate andStoreEndTime: (NSString *) sEndTime andStoreTotalSales: (NSString *) sTotalSales andStoreVoids: (NSString *) sVoids andStoreDiscounts: (NSString *) sDiscounts andStoreGuestCount: (NSString *) sGuestCount andStorePeopleServed: (NSString *) sPeopleServed andStoreEmployeeClockIn: (NSString *) sEmployeeClockIn andStoreAddress: (NSString *) sAddress];

                //Add our city object to our cities array
                [storesArray addObject:myStore];
            }




            [self.myTableView reloadData];


        }

    @end

最佳答案

要从另一个 Storyboard实例化 View Controller ,您可以使用UIStoryboard storyboardWithName

UIViewController *dvc = [[UIStoryboard storyboardWithName:@"yourStoryboardName" bundle:nil] instantiateViewControllerWithIdentifier:@"yourViewIdentifier"];
[self.navigationController pushViewController:dvc animated:YES];

不过,这是一个更笼统的答案。

关于ios - 不能在 Storyboard之间继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23465260/

相关文章:

javascript - 如何将附加文本附加到 UIWebView

iphone - UIButton - 编程创建问题

swift - 通过模态 segue 为按钮创建操作。无法控制拖动,Swift

ios - ( swift )PrepareForSegue : fatal error: unexpectedly found nil while unwrapping an Optional value

ios - ERROR : BOMStream BOMStreamWithFileAndSys(int, off_t, size_t, int, char *, BomSys *): read: No such file or directory in iOS

ios - 是否可以从网站中的某些链接打开 iOS 应用程序?

android - 如何在 Google Drive 和 Dropbox 上为 Flutter 应用备份用户数据?

objective-c - 添加额外的 UIImage 到 TTPhotoViewController

ios - 标题 View 字段 iOS 上的阅读水龙头

swift - Swift 中的多 View Controller 导航