iphone - 应用程序崩溃并发送到已释放实例的错误消息

标签 iphone ios uitableview uiviewcontroller datasource

在我的 UIViewController 中,我添加了一个包含 uitableview 的 subview 。

MSEmployeeServiceController *empServices = [[MSEmployeeServiceController alloc]initWithNibName:@"MSEmployeeServiceController" bundle:nil];
[self.totScroll addSubview:empServices.view];

MSEmployeeServiceController 类包含一个 UITableView。当我尝试添加 View 应用时崩溃并出现以下错误:

-[MSEmployeeServiceController numberOfSectionsInTableView:]: message sent to deallocated instance 0x8684030

我已经在 View 中设置了数据源和委托(delegate)连接。 请帮助我。

最佳答案

如果您使用的是 ARC,请在您的头文件

中将 MSEmployeeServiceController 的对象设为这样的属性
@property (strong, nonatomic)  MSEmployeeServiceController *empServices;

然后在你的实现文件中,

_empServices = [[MSEmployeeServiceController alloc]initWithNibName:@"MSEmployeeServiceController" bundle:nil];

[self.totScroll addSubview:empServices.view];

关于iphone - 应用程序崩溃并发送到已释放实例的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17967511/

相关文章:

iphone - 如何将后置摄像头实时视频显示到 UIImageView?

ios - 检测 UITableView 下面的 UIPageView 上的滑动事件

ios - 为什么我的 UIPanGestureRecognizer 没有被检测到并触发该方法?

ios - 我可以将私有(private)变量传递给将通过 Storyboard 实例化的 UIViewController 吗?

ios - Facebook SDK didLoad :result = null

ios - UITableviewCell 高度未在滚动时重置

iphone - 继承 UIViewController 类和 XIB

iphone - 进入后台后动画使应用程序崩溃

iPhone UIDatePicker 设置MaximumDate

ios - DispatchQueue.main.async 的多个请求在 swift 3 中无法正确执行