【发布时间】:2012-05-09 15:19:43
【问题描述】:
我创建了一个工具栏。就像这样:
UIToolbar *toolbar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, toolBarHeight)];
toolbar.autoresizingMask=UIViewAutoresizingFlexibleWidth;
UIBarButtonItem *itemNull=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil] autorelease];
UIBarButtonItem *item0=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item1=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item2=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item3=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(pre)]
autorelease];
UIBarButtonItem *item4=[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(pre)] autorelease];
itemNull.width=frame.size.width-itemwidth*5;
item0.width=itemwidth;
item1.width=itemwidth;
item3.width=itemwidth;
item4.width=itemwidth;
item2.width=itemwidth;
[toolbar setItems:[NSArray arrayWithObjects: itemNull,item0,item1,item2,item3,item4, nil]];
[self addSubview:toolbar];
[toolbar release];
它被添加到视图中。但是当我旋转视图时,这些项目不在标志上。 我想知道如何让它可见而不是重置它的框架。 这些项目是否具有 autoresize 之类的属性?
【问题讨论】:
-
可能重复,但请参阅此链接。 stackoverflow.com/questions/2128961/…
-
你能显示一些屏幕截图来解决这个问题吗?
标签: objective-c ios toolbar autoresize