[英]Bottom toolbar buttons flashes for a second?
這個小問題真的困擾着我。
我有分層的導航控制器:RootView-> 2ndListView-> DetailView
我在DetailView上輕松實現了帶有按鈕的底部工具欄。 在那里完美工作。
但是,在2ndListView中,當我遵循相同的操作並將以下代碼放入viewdidload或viewwillappear或任何其他類似方法中時,該按鈕將在視圖加載時閃爍一秒鍾,然后隱藏。
相反,如果我將這段代碼放在cellForRowAtPathIndex中(以便在此之后不執行任何操作),那么它將起作用。 但這顯然效率很低。
因此,兩者之間發生了一些事情。 可能是什么問題?
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.