iphone - 触摸时 UIScrollView 使应用程序崩溃

标签 iphone uiviewcontroller crash

我遇到了一个非常烦人的问题:我正在创建一个 UIScrollView,其中包含一个包含一些按钮的 UIView。带有按钮的 UIView 工作正常。但是 UIScrollView,无论我用它做什么,当触摸它时,它都会崩溃。它是否为空没有任何区别。它一直在崩溃。

我很迷茫,不知道还能尝试什么。
非常感谢。

在 viewController.h

@interface tagstestViewController : UIViewController <UIScrollViewDelegate> {
        UIScrollView            *scrollViewContainer;
}

@property (nonatomic, retain) UIScrollView *scrollViewContainer;

在 viewController.m 中:
    UIScrollView *scv       =   [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, 320, 200)];
    scv.backgroundColor     =   [UIColor blackColor];
    scv.autoresizingMask    =   UIViewAutoresizingFlexibleHeight;   
    scv.bounces             =   YES;
    scv.scrollEnabled       =   YES;
    scv.clipsToBounds       =   YES;
    scv.delegate            =   self;

    [self setScrollViewContainer:scv];

    [scv release];

    [self.view addSubview:scrollViewContainer];

最佳答案

您是否在将 View 添加到 View 层次结构后立即释放 View Controller ?因为如果你这样做,我注意到即使应用程序一直运行良好,如果你使用“scv.delegate = self”,它会在尝试将委托(delegate)消息传递到 viewController 时崩溃。

关于iphone - 触摸时 UIScrollView 使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3299526/

相关文章:

ios - 查看将消失 : Determine whether view controller is being popped or is showing a sub-view controller

ios - Parse.com 在 iOS 7.0 上的基本项目崩溃

iphone - 键值观察对 UITextView 的 Text 属性有效吗?

iPhone:如何在自定义单元格的动态数量上管理 UITextfield 委托(delegate)方法

iphone - 标准 View 和 UITabBarController View 之间的转换?

swift - 静态容器 View

iphone - NSDateComponents - 返回错误日期的日期方法

iphone - UITableView自定义Cells、滚动和内存管理

sql-server - Visual Studio 2008 集成开发环境崩溃

c++ - 程序在退出时崩溃