Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIView与UITableView滚动崩溃应用程序_Ios_Iphone_Objective C_Uitableview_Uiview - Fatal编程技术网

Ios UIView与UITableView滚动崩溃应用程序

Ios UIView与UITableView滚动崩溃应用程序,ios,iphone,objective-c,uitableview,uiview,Ios,Iphone,Objective C,Uitableview,Uiview,我创建了一个包含UIView、UIToolbar和UITableView的UIViewController。 这就是我创建视图所做的 将元素连接到Interfacebuilder中的IBOutlet 在类标题中调用UITableViewDelegate和DataSource 然后我试着像这样在ViewDidLoad中设置视图 - (void)viewDidLoad { [super viewDidLoad]; colorController = [[ColorControll

我创建了一个包含UIView、UIToolbar和UITableView的UIViewController。 这就是我创建视图所做的

  • 将元素连接到Interfacebuilder中的IBOutlet
  • 在类标题中调用UITableViewDelegate和DataSource
然后我试着像这样在ViewDidLoad中设置视图

- (void)viewDidLoad
{
    [super viewDidLoad];
    colorController = [[ColorController alloc] init];
    [colorController readColorPlist];

    //create toolbar
    myToolBar = [[UIToolbar alloc] init];
    [myToolBar setTranslucent:NO];
    myToolBar.frame = CGRectMake(0.0, 0.0, 320.0, 45.0);
    [[UIToolbar appearance] setBarTintColor:[UIColor colorWithRed:colorController.oRed/255.0 green:colorController.oGreen/255.0 blue:colorController.oBlue/255.0 alpha:1.0]];

    // add title to toolBar
    UILabel *toolBarLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 110.0) / 2, 3.0, 110.0, 40.0)];
    toolBarLabel.font = [UIFont boldSystemFontOfSize:16];
    toolBarLabel.textAlignment = NSTextAlignmentCenter;
    toolBarLabel.textColor = [UIColor whiteColor];
    toolBarLabel.backgroundColor = [UIColor clearColor];
    toolBarLabel.text = @"My View";

    // create TableView
    myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 45.0, self.view.frame.size.width, self.view.frame.size.width - 65)];
    [myTableView setDelegate:self];
    [myTableView setDataSource:self];

    // createButtons
    // create an array for the buttons
    NSMutableArray* barButtonsArray = [[NSMutableArray alloc] initWithCapacity:5];

    // create a Cancel button
    UIBarButtonItem * cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel"
                                                                      style:UIBarButtonItemStylePlain
                                                                     target:self
                                                                     action:@selector(cancelUIButton)];

    cancelButton.style = UIBarButtonItemStyleBordered;
    cancelButton.tintColor = [UIColor whiteColor];
    [barButtonsArray  addObject:cancelButton];

    UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    [barButtonsArray addObject:flexible];

    // create a submitButton
    UIBarButtonItem *submitButton = [[UIBarButtonItem alloc]initWithTitle:@"Submit"
                                                                    style:UIBarButtonItemStylePlain
                                                                   target:self
                                                                   action:@selector(submitButton)];
    submitButton.style = UIBarButtonItemStyleBordered;
    submitButton.tintColor = [UIColor whiteColor];
    [barButtonsArray  addObject:submitButton];

    // put the BarbuttonsArray in the toolbar and release them
    [myToolBar setItems:barButtonsArray  animated:NO];



    // add the views
    [self.view addSubview:myTableView];

    [self.view addSubview:myToolBar];
    [myToolBar addSubview:toolBarLabel];

}
我还确保在这个类中设置了DataSource和tableView委托

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
当我试图滚动UITableView时,它崩溃了,这就是它所说的

Thread 1:EXC_BAD_ACCESS(code=1, address=0x415dc466)'
没有任何内容输出到控制台,因此很难理解此错误的含义

更新1:cellForRowAtIndexPath方法 更新2:堆栈跟踪 它显示与工具栏或视图中的任何UIButton的任何交互都会导致错误。下面是堆栈跟踪

<_NSCallStackArray 0x14ebf7b0>(
0   ???                                 0x028d1654 0x0 + 42800724,
1   HelloWorld                           0x00025f99 main + 0,
2   UIKit                               0x2ff0bf7b <redacted> + 266,
3   UIKit                               0x2fefa739 <redacted> + 196,
4   UIKit                               0x2fda518b <redacted> + 1138,
5   UIKit                               0x30130d4f <redacted> + 46,
6   UIKit                               0x2fd6c5cf <redacted> + 218,
7   UIKit                               0x2fd6ad33 <redacted> + 298,
8   UIKit                               0x2fda39fd <redacted> + 772,
9   UIKit                               0x2fda33ab <redacted> + 666,
10  UIKit                               0x2fd78d79 <redacted> + 196,
11  UIKit                               0x2fd77569 <redacted> + 7116,
12  CoreFoundation                      0x2d5baf1f <redacted> + 14,
13  CoreFoundation                      0x2d5ba3e7 <redacted> + 206,
14  CoreFoundation                      0x2d5b8bd7 <redacted> + 630,
15  CoreFoundation                      0x2d523471 CFRunLoopRunSpecific + 524,
16  CoreFoundation                      0x2d523253 CFRunLoopRunInMode + 106,
17  GraphicsServices                    0x322572eb GSEventRunModal + 138,
18  UIKit                               0x2fdd8845 UIApplicationMain + 1136,
19  HelloWorld                           0x0002600d main + 116,
20  libdyld.dylib                       0x37e49ab7 <redacted> + 2
)
(
0°?0x028d1654 0x0+42800724,
1 HelloWorld 0x00025f99主节点+0,
2 UIKit 0x2ff0bf7b+266,
3 UIKit 0x2fefa739+196,
4 UIKit 0x2fda518b+1138,
5 UIKit 0x30130d4f+46,
6 UIKit 0x2fd6c5cf+218,
7 UIKit 0x2fd6ad33+298,
8 UIKit 0x2fda39fd+772,
9 UIKit 0x2fda33ab+666,
10 UIKit 0x2fd78d79+196,
11 UIKit 0x2fd77569+7116,
12芯基础0x2d5baf1f+14,
13芯基础0x2d5ba3e7+206,
14芯基础0x2d5b8bd7+630,
15 CoreFoundation 0x2d523471 CFRunLoopRunSpecific+524,
16 CoreFoundation 0x2d523253 CFRUNLOOPSRUNINMODE+106,
17图形服务0x322572eb GSEventRunModal+138,
18 UIKit 0x2fdd8845 UIApplicationMain+1136,
19 HelloWorld 0x0002600d干管+116,
20 libdyld.dylib 0x37e49ab7+2
)

请发布崩溃消息。我已更新了错误代码。。很抱歉,这里没有足够的信息进行诊断。请发布完整的堆栈跟踪。转到Xcode中的断点导航器并单击左下角的加号(+)。选择“添加异常断点”。然后试着运行你的应用程序,你可能会看到它崩溃的代码行。这意味着你的ViewController已经被解除分配,这很奇怪。可能会在创建viewController的位置发布代码(来自appDelegate?)。另外,发布stacktrace(从中获得EXC_断点)。
<_NSCallStackArray 0x14ebf7b0>(
0   ???                                 0x028d1654 0x0 + 42800724,
1   HelloWorld                           0x00025f99 main + 0,
2   UIKit                               0x2ff0bf7b <redacted> + 266,
3   UIKit                               0x2fefa739 <redacted> + 196,
4   UIKit                               0x2fda518b <redacted> + 1138,
5   UIKit                               0x30130d4f <redacted> + 46,
6   UIKit                               0x2fd6c5cf <redacted> + 218,
7   UIKit                               0x2fd6ad33 <redacted> + 298,
8   UIKit                               0x2fda39fd <redacted> + 772,
9   UIKit                               0x2fda33ab <redacted> + 666,
10  UIKit                               0x2fd78d79 <redacted> + 196,
11  UIKit                               0x2fd77569 <redacted> + 7116,
12  CoreFoundation                      0x2d5baf1f <redacted> + 14,
13  CoreFoundation                      0x2d5ba3e7 <redacted> + 206,
14  CoreFoundation                      0x2d5b8bd7 <redacted> + 630,
15  CoreFoundation                      0x2d523471 CFRunLoopRunSpecific + 524,
16  CoreFoundation                      0x2d523253 CFRunLoopRunInMode + 106,
17  GraphicsServices                    0x322572eb GSEventRunModal + 138,
18  UIKit                               0x2fdd8845 UIApplicationMain + 1136,
19  HelloWorld                           0x0002600d main + 116,
20  libdyld.dylib                       0x37e49ab7 <redacted> + 2
)