开发者

Set title of SplitViewController

I am using the SplitViewController template. How do I set the 开发者_Go百科title on the topbar in the detailview? Been trying to work this out for hours. Tried simple:

detailViewController.title = @"String";

but no luck.

Any help appreciated. Thanks.


Assuming it's a toolbar that you're attempting to add a title to, why not add a UIBarButton with

UIBarButton *barButtonItem = [[UIBarButton alloc] initWithTitle:@"Foo" style:UIBarButtonItemStylePlain target:self action:nil

With a little computation hoop jumping you could figure out the width to place this item somewhere in the middle of the toolbar. Then make it so with a

barButtonItem.width = whatever;

Then add the item to the mutableArray from above and then to the toolbar like

[toolBarArray insertObject:barButtonItem atIndex:x];
[toolbar setItems:toolBarArray animated:YES];

This will work on the iPhone/Touch with the 3.1 SDK, I can't (legally) say anything about the 3.2 until April 3...


The title of the detail view is determined by the either the title of the item in the root view or by content entered in the detail. I don't think its something that you can assign programmatically. You can change the root view title in IB, though.


you need to set it via UIToolbar that is inside DetailViewController. You need to have that UIToolbar to have a BarButtonItem inside it, and reference this BarButtonItem to an IBOutlet of your controller. The template you use dont have BarButtonItem on it by default, you need to add this by yourself. Sometimes you need to add an extra Flixible or Fixed Space Bar item with it.

Once you have it linked on your controller, e.g:

@property (nonatomic, retain) IBOutlet UIBarButtonItem *toolbarItem;

then you can set its title via its title attribute:

toolbarItem.title = @"String";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜