Xcode-segue工作,然后后退按钮崩溃应用程序

时间:2016-07-19 04:48:07

标签: ios objective-c iphone uibutton segue

我有一个TopicsViewController,显示由学生热门研究主题标记的UIButtons。

TopicsViewController:

enter image description here

TopicsViewController.m有一个prepareForSegue方法成功地将数据传递给我的StatsViewController,后者显示所选主题的统计信息标记的UIButtons。这些统计信息是从ThemeViewController类传递到StatsViewController类中的NSString属性的NSStrings。

在TopicsViewController.m中:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}

StatsViewController:

enter image description here

StatsViewController.m有一个prepareForSegue方法,成功地将数据传递给我的CiteViewController,它显示了由MLA标记的UIButtons和所选统计数据的APA引用。这些引用的传递方式与统计数据从一个类到另一个类的传递方式相同。

在StatsViewController.m中:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}

CiteViewController:

enter image description here

然后,“引用”页面将URL传递给SourceViewController以显示与源关联的UIWebView,但此页面没有任何问题。

的问题:

点击“< “统计信息”页面上的“热门主题”按钮(分段回到TopicsViewController),应用程序崩溃,异常断点位于以下行:

enter image description here

调试器显示TopicsViewController上的UIButtons为nil:

enter image description here

点击“< “引用”页面上的“统计信息”按钮(转换回StatsViewController),应用程序崩溃,异常断点位于以下行:

enter image description here

调试器显示StatsViewController上的NSStrings为nil:

enter image description here

这就是我所发现的。非常感谢您提前回复任何回复。

0 个答案:

没有答案