UIViewController不继承导航栏

时间:2015-06-02 15:09:40

标签: ios objective-c uiviewcontroller uinavigationcontroller

我有一个相当大的iOS应用程序,大约有20个视图控制器都嵌入在一个导航视图控制器中,因此处理"返回"按钮动作。由于某种原因,其中一个视图控制器上没有导航栏,我不知道为什么。有任何想法吗?

以下是没有导航栏的VC代码:

#import "selectCombos.h"
#import "combos.h"

@interface selectCombos ()

@end

NSString *docDir;
NSString *filePath;
NSArray *allComboString;
NSString *userCombosString;
NSArray *userCombosReadIn;
NSString *tempSelectName;

@implementation selectCombos
@synthesize selectedComboString;

- (void)viewDidLoad {
    [super viewDidLoad];

    self.fileManager =[NSFileManager defaultManager];
    userCombosReadIn = [[NSArray alloc] init];
    NSArray *paths =  NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    docDir = [paths objectAtIndex:0];
    filePath =[docDir stringByAppendingPathComponent:@"userCombosFile.txt"];
    userCombosString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    if(userCombosString == nil)
    {
        userCombosString = @"";
    }
    userCombosReadIn = [userCombosString componentsSeparatedByString:@"-"];

    if (self.sentBackSelectedCombo == nil) {
        //do nothing
    }
    else{

    }

    [self.tableView setDelegate:self];
    [self.tableView setDataSource:self];

    }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) loadCombos
{
    //use this info to load up the uipickerview
}



-(NSInteger)numberOfSectionsInTableView:(UITableView *) tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return ([userCombosReadIn count] - 1);
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"Combos";
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *myID = @"MyReuseId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:myID];
    if(cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myID];
    }

    NSArray *splitReadIn = [[userCombosReadIn objectAtIndex:indexPath.row] componentsSeparatedByString:@","];
    NSString *nameForCell = [splitReadIn objectAtIndex:0];
    cell.textLabel.text = nameForCell;
    return  cell;
}

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.contentView.backgroundColor = [UIColor clearColor];
}

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //get which one it is and send it back to the other viewcontroller!!!!

    NSArray *tempComboArray = [[userCombosReadIn objectAtIndex:indexPath.row] componentsSeparatedByString:@","];
    tempSelectName = [tempComboArray objectAtIndex:0];

    for (int i = 0; i < [userCombosReadIn count]; i++) {
        NSArray *tempCompareArray = [[userCombosReadIn objectAtIndex:i] componentsSeparatedByString:@","];
        if ([tempSelectName isEqualToString:[tempCompareArray objectAtIndex:0]]) {
            self.selectedComboString = [userCombosReadIn objectAtIndex:i];
            break;
        }
    }

    [self performSegueWithIdentifier:@"unwindToSelectCombos" sender:self];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    combos *cvc = [segue destinationViewController];
    cvc.sentBackSelectedCombo = self.selectedComboString;
    NSLog(cvc.sentBackSelectedCombo);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)testButtonAction:(id)sender {
    [self performSegueWithIdentifier:@"unwindToSelectCombos" sender:self];
}
@end

0 个答案:

没有答案
相关问题