开发者

How to stop UITableView from attaching to the top

I'm new to iPhone and having a hard time getting this one done. I know it's possible but can't find a way. I have UIView that has a UIToolbar and a UITableView in it. I'm using IB and can see the toolbar at the top of the page and TableView below it but when I rum my application it only shows the TableView, the Toolbar for some reason is not shown (TableView covers it!).

Any help is appreciated, I hopt to to find a setting in IB but if I need to code for it that would be fine too. I've already tried setting the tableview's frame size (self.tableView.frame = CGRec开发者_如何学GotMake(0, 100, 320, 100);) but this did nothing!

Thanks


IB just shows the area of Toolbar not the actual toolbar its for designing purpose. You have to do it manually.


First off if your not using a ViewController class please do so.

In IB place your table and toolbar inside a view, then set the view to the fileOwner(tableToolViewController)

Your header file of the view controller class should look something like this

  @interface tableToolViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {


    IBOutlet UITableView    *theTableView;
    IBOutlet UIToolbar      *yourToolbar

Now connect your outlets to your table and tool bar and that should do the trick

For calls that use self.tableView just use theTableView outlet instead


Well I managed to resolve the issue. Just explaining it here so other who may have the same problem can benefit.

I started with what Matt suggested but it didn't help. Then I created a new project and started playing with different combinations of UIView and UITableView controllers and layouts.

It seems if the view controller is defined of type UITableViewController instead of defining it as UITableVC and the file owner is hooked to a tableview then the TV is expanded to cover the whole window and there is nothing you can do (I couldn't find a way!).

Even if you change the class definition and make it to extend UIViewController still this won't resolve the issue (strange!) but if simply create a new class extend UIViewController and copy paste all your code from old class and make sure file owner if hooked to the UIView then all works fine.

I'm sure there is an explanation for all this but for now I'm happy I can build what I want.

Thanks for the replies and help and happy coding.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜