[英]Bottom toolbar buttons flashes for a second?
this little issue is really getting on me. 这个小问题真的困扰着我。
I have hierarchal navigation controller: RootView-->2ndListView-->DetailView 我有分层的导航控制器:RootView-> 2ndListView-> DetailView
I implemented bottom toolbar with buttons easily on the DetailView. 我在DetailView上轻松实现了带有按钮的底部工具栏。 Works perfectly there.
在那里完美工作。
However, in the 2ndListView, when I follow the same thing and put the following code in either viewdidload or viewwillappear or any other similar method, the button just flashes for a second when the view loads, and then hides. 但是,在2ndListView中,当我遵循相同的操作并将以下代码放入viewdidload或viewwillappear或任何其他类似方法中时,该按钮将在视图加载时闪烁一秒钟,然后隐藏。
Instead, if I put up this code in cellForRowAtPathIndex (so that nothing is executed after that), it does work. 相反,如果我将这段代码放在cellForRowAtPathIndex中(以便在此之后不执行任何操作),那么它将起作用。 But this is obviously very inefficient.
但这显然效率很低。
So there is something happening in between. 因此,两者之间发生了一些事情。 What could be the issue?
可能是什么问题?
NSMutableArray *array;
NSMutableArray *tags;
@implementation SMSListViewController
@synthesize smses,catID,addButtonItem,filteredSMS,searchBar,searchController;
-(void)getStarted{
array = [[NSMutableArray alloc] init];
tags = [[NSMutableArray alloc] init];
SMSDBAccess *smsDBAccess = [[SMSDBAccess alloc] init];
smsDBAccess.catID = self.catID;
self.smses = [smsDBAccess getAllItems];
[smsDBAccess closeDatabase];
[smsDBAccess release];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc {
[array release];
[smses release];
[super dealloc];
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationController setToolbarHidden:NO];
self.navigationItem.rightBarButtonItem = self.editButtonItem;
UIBarButtonItem *addSMSButoon = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(addSMS:)];
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
NSArray *buttons = [NSArray arrayWithObjects:space,addSMSButoon, nil];
[self.navigationController.toolbar setItems:buttons animated:NO];
[addSMSButoon release];
[space release];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self getStarted];
[self.tableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [smses count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
SMS *aSMS = [self.smses objectAtIndex:indexPath.row];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text =aSMS.sms;
cell.detailTextLabel.text=aSMS.sms;
return cell;
}
@end
navigationController
在整个导航堆栈之间共享,因此,如果在某个地方将navigationController
的项目设置为nil
(也许在viewDidDisappear
调用中),则在新的视图控制器对其进行设置后,这些项目将消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.