【发布时间】:2011-05-12 12:26:46
【问题描述】:
我正在使用 sdk 中的 initWithFrame: 方法初始化的视图中使用 uitoolbar。我的意思是我正在以编程方式添加工具栏。在多任务处理时,此工具栏会产生问题。任何人都可以给我一些解决方案或一束光来继续。我无法在 xib 中添加它,因为我使用的是自定义 uitablecontroller 类。我的代码如下:
-(void)viewDidLoad
{
[super viewDidLoad];
actionToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 373, 320, 44)];
[actionToolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top-bar.png"]] autorelease] atIndex:0];
actionButton = [NotesList createSquareBarButtonItemWithTitle:@"Delete" target:self action:@selector(noAction:)];
flexibleSpace1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
flexibleSpace2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
composeButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(addNewGroup:)]autorelease];
composeButton.style = UIBarButtonItemStylePlain;
[actionToolbar setItems:[NSArray arrayWithObjects:flexibleSpace1, flexibleSpace2, composeButton, nil]];
[self.view.superview addSubview:actionToolbar];
self.tableView.frame = CGRectMake(0, 0, 320, 400);
[self.tableView setAllowsSelectionDuringEditing:YES];
[flexibleSpace1 retain];
[flexibleSpace2 retain];
[actionButton retain];
[composeButton retain];
[self parseDataForThisFile];
}
【问题讨论】:
-
想澄清您遇到的问题?除非你让我知道发生了什么,否则我无能为力
-
你的问题到底是什么??
-
我的问题是当应用程序从后台返回时,最初位于视图底部的工具栏移动到导航控制器下方的视图顶部。这只发生在多任务处理和调用 applicationWillEnterForeground 方法之后。
标签: iphone ios4 multitasking uitoolbar