开发者

iPhone: Image View and buttons under a TableView

Hi guys I have a table view but I don't want it to fill al the screen let's say I want it to be 320x420. Well I want to put under the table view an image like a bar an image that would be 320x60. The first time I tried this the image went down to the section footer of the table view and I wasn't able to see it until I get to the bottom of the table view. After that I tried on the IB to resize the tableview and put under it the image, but when I tried it on the simulator the image didn't show up. I thought I was because the File's Owner view outlet was connected to the table view, so after that I disconnected with it and connected with the view that contained the table view, and when I tried in the simulator it crashed. So I was looking on internet but still I can't fi开发者_开发知识库nd the answer. I don't know if you actually understood well my problem, cause my english kinda sucks. Best Regards Carlos Vargas


You don't need to connect the UIImageView to anything in the view. It will get loaded and placed automatically. The only reason you might want to connect it to anything is if you want to change something in it programmatically in the controller, and in that case you'd connect it to an IBOutlet in the controller.

I think what you need to do is create a UIView, then put the table view and the UIImageView inside the UIView. In IB it will look something like:

  __
  \/View           UIView
      Table View   UITableView
      Image        UIImageView

You should be able to resize the subviews the way you want.

In the controller (File's Owner) make sure you have outlets for both View and Table View, then connect those views to the corresponding outlet. (Really you don't need to connect Table View to anything unless you need to directly configure it from the controller somehow. Setting the delegate and datasource properly should be enough.) Make sure to connect delegate and dataSource in the table view to the controller as usual. Make sure the view outlet in file's owner is connected to View and not TableView!

Your controller doesn't need to be a subclass of UITableViewController, it just needs to support the protocols. In fact, in this case using UITableViewController might not work because it may get "confused" if view is not set to a table view.

I just did this and it worked. In my case, though, I put an info button over the table view and did some other stuff.

Hope that helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜