开发者

Connection fault in IB

开发者 https://www.devze.com 2022-12-19 04:52 出处:网络
I have a Tab Bar application with four new headers, implementation and interface files, and added 开发者_Go百科those as the sources in IB. They were in this format: FirstView.h/m/xib, SecondView.h/m/x

I have a Tab Bar application with four new headers, implementation and interface files, and added 开发者_Go百科those as the sources in IB. They were in this format: FirstView.h/m/xib, SecondView.h/m/xib.

I then had files for First-, Second-, Third- and FourthView. There was also a file there called FirstViewController. I did not touch this, I just deleted it because I wasn't going to need it.

I then laid out my interface for the first view (FirstView.h/m/xib) in IB. It had an image on the top, label under and a UITableView under that.

I sat up the correct connections (delegations and datasource for the tableview) in my FirstView.h/m file, and pressed Build. It seemed to build without errors, so I pressed Build and Go.

The Simulator popped up, installed the app and crashed. (Error message:Terminating app due to uncaught exception).

Complete error message:

2010-02-06 21:50:54.733 Mudo[52439:207] *** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0
2010-02-06 21:50:54.735 Mudo[52439:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[FirstViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x39101a0'
2010-02-06 21:50:54.736 Mudo[52439:207] Stack: (**LotsOfNumbers**)

I asked about this in another question, got an answer, and that fixed it:

It was obviously looking for code in the FirstViewController.h/m-file, although I did not do anything to make it look for code there.

I fixed this by adding two interfaces and implementations in my FirstView.h/m file. (FirstView and FirstViewController)

When I ran the app then, the table view and tab bar came up on the screen, but my image and label did NOT. I don't have any idea of why it was looking for the code in FirstViewController instead of FirstView... I have the correct connections in IB, too..


A tableview is trying to query its data source for the number of rows it should display. If you've connected the tableview's datasource outlet to an instance of your FirstViewController class, then you need to implement -tableView:numberOfRowsInSection: in that class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号