【问题标题】:Things don't work after performing Segue执行 Segue 后事情不起作用
【发布时间】:2014-09-02 20:15:56
【问题描述】:

我有以下问题:我有一个带有 UIScrollView 和 UICollectionView 的 ViewController。当我直接在此视图控制器上启动应用程序时,一切正常。当我从另一个 ViewController(这里是 Google Maps SDK 地图)调用 ViewController 时,会加载 ViewController,但是当我尝试滚动时,会收到此消息,并且应用会停止:

*** -[TheSecondViewController respondsToSelector:]: message sent to deallocated instance 0x16ef3890

这里还有一些代码: 调用视图:

-(void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {

     [self performSegueWithIdentifier:@"OpenSecondView" sender:self];

}

第二个视图中的viewDidLoad:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view.

    if (IS_IPHONE5) {

        self.scrollV.frame = CGRectMake(0, 0, 320, 568);
        NSLog(@"Das Geraet ist ein iPhone 5 / iPhone 5S");

    } else {

        self.scrollV.frame = CGRectMake(0, 0, 320, 480);
        NSLog(@"Das Geraet ist ein iPhone 4 / iPhone 4S");

    }

    [self.view bringSubviewToFront:scrollV];

    [scrollV setScrollEnabled:YES];
    [scrollV setDelegate:self];
    [scrollV setContentSize:CGSizeMake(320, 833)];
    [collectionV setScrollEnabled:NO];

    activityInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;

    [activityInd startAnimating];

    [imageView setUserInteractionEnabled:YES];

}

【问题讨论】:

  • 请提供更多细节和源代码
  • 从SecondViewController的viewDidLoad中提供一些源码
  • 您的某些属性似乎缺少强参考。请发布更多信息。
  • 我将两个属性从弱改为强。现在我得到一个 EXC_BREAKPOINT...
  • 也许您可以添加该代码以查看发生了什么。

标签: ios objective-c iphone uiscrollview


【解决方案1】:

知道您刚刚加载了 secondViewController,看起来您的 secondViewController 没有正确分配(而不是被释放)。尝试使用在情节提要中创建的转场并使用代码调用这些转场,和/或使用对视图的强引用而不是弱引用

【讨论】:

  • 我现在解决了这个问题。我更改了一些属性并删除了模拟器数据。现在它可以工作了......
猜你喜欢
  • 2014-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多