2011-05-12 61 views
0

我在使用sdk中的initWithFrame:方法初始化的视图中使用了uitoolbar。我的意思是我添加工具栏porgramously。多任务时,这个工具栏正在创建问题。任何人都可以给我一些解决方案或光线来继续。我不能在xib中添加它,因为我正在使用自定义的uitablecontroller类。我的代码如下:UIToolBar在应用程序从后台返回时创建问题

-(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]; 
} 
+0

应用的回报要澄清你所遇到的问题的代码?我不能帮助,除非你让我知道发生了什么 – theiOSDude 2011-05-12 12:41:24

+0

你的问题到底是什么? – 2011-05-12 12:42:26

+0

我的问题是,当应用程序从后台返回时,最初位于视图底部的工具栏移动到导航控制器正下方的视图顶部。只有在多任务处理和applicationWillEnterForeground方法被调用后,才会发生这种情况。 – DivineDesert 2011-05-12 13:28:39

回答

0

我已经解决了通过设置标签栏控制器的帧时从后台

0

即使使用自定义UITableViewController子类,也可以使用NIB文件。可以在Interface Builder的检查器的标识选项卡上指定要使用的确切类。 Class Identity http://www.peylow.se/ClassIdentity.png

如果您在多任务时遇到问题,那么我怀疑您没有正确处理卸载视图。进入后台时,您的应用可以从视图控制器卸载视图,以释放更多内存。

确保在loadViewviewDidLoad中设置/创建的任何连接也可以在viewDidUnload中正确断开/释放,这一点非常重要。否则,奇怪的和意想不到的事情会发生在你的应用程序中

+0

对不起,我无法这样使用它。我尝试过,但不能改变那里的课程名称。 – DivineDesert 2011-05-12 13:22:02

+0

@Dimple Panchal - 为什么?您编写类名的文本字段是**从不**只读。请注意,如果您需要自定义设置,则必须根据需要重写'initWithCoder:'或'awakeFromNib'。 – PeyloW 2011-05-12 13:27:59

+0

我的自定义类没有任何xib文件。所以可能是这个原因。我不确定原因,但我怀疑这个原因。我一开始就试过这个。 – DivineDesert 2011-05-12 13:39:16

相关问题