[英]How to hide the rightBarButtonItem when navigating from tabbar?
[英]How to navigate to the tableView when the rightBarButtonItem is pressed?
我是iPhone應用程序開發的新手。 在我的代碼中,選擇圖像並按下完成的rightBarButtonItem之后,我想導航到表視圖,在其中顯示所選圖像的所有zip文件。 選擇帶有完成按鈕的圖像和tableView都在不同的viewControllers中。 當我通過修改代碼按下完成按鈕時,請告訴我如何導航至tableView。
這是我的代碼查找完成的條形按鈕的方式:
- (void)updateRightBarButtonItem
{
if (self.allowsMultipleSelection) {
// Set done button
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)];
doneButton.enabled = NO;
[self.navigationItem setRightBarButtonItem:doneButton animated:NO];
self.doneButton = doneButton;
}
這就是我的tableView代碼的外觀:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger) tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger) section
{
return [filePathsArray count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:@"Main Cell"];
if(cell== nil)
{
cell= [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @"Main Cell"];
}
cell.accessoryType= UITableViewCellAccessoryDetailDisclosureButton;
for(int i=0;i<[filePathsArray count];i++)
{
if(indexPath.row==i)
cell.textLabel.text=[filePathsArray objectAtIndex:i];
}
return cell;
}
在rightBarButton選擇器中,您可以將(導航)到所需的視圖。
您必須在選擇器定義的地方#import "YOurViewControllerName.h"
。
-(void) done
{
YOurViewControllerName * = [[YOurViewControllerName alloc] initWithNibName:@"YOurViewControllerName" bundle:nil];
[self.navigationController pushViewController:tableVC animated:YES];
[addCreateAlarmVC release]; //if non ARC
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.