这是一个非常简单的问题,但我不知道为什么会发生。在我的头文件中,我声明了一个UIButton *leftButton
。在viewDidLoad方法中,我这样做:leftButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
然后在其他某个方法中,我有:
leftButton.frame=newFrame;
leftButton.tag=i;
[leftButton addTarget:self action:@selector(leftButtonSelected:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:leftButton];
然而,当调用上述方法时,我一直遇到崩溃问题。有时我会收到一条消息,有时它只是无任何消息地崩溃了。我无法复制任何崩溃消息,现在我只是得到一个一般性的崩溃,但它一直从奇怪的问题中崩溃,例如[UIGestureRecognizer setFrame]引起问题或[WebView setFrame]或其他什么东西...出于某种原因,它一直认为leftButton不是UIButton,但这并不是事实。我的整个项目中没有其他名为leftButton的东西。有什么想法吗?