IOS Second App - + Button消失了

时间:2013-04-07 15:52:23

标签: ios xcode

我是IOS应用程序编程的新手 - 我通过了iOS second app tutorial(看到它的鸟),当我到达终点时我有2个问题,任何指针都会受到最多的赞赏。

  1. 主视图上的+按钮消失了,我不明白为什么?哪部分代码支配这个?

  2. 在主视图中选择鸽子鸟时,会出现详细视图,但所有项目中仍有详细信息,因此鸟名仍然是细节,位置仍然是细节等。

  3. 非常感谢任何帮助。

    由于

    编辑 - 添加了masterviewcontroller的.h和.m代码

    ·H

    #import <UIKit/UIKit.h>
    @class BirdSightingDataController;
    @interface BirdsMasterViewController : UITableViewController
    @property (strong, nonatomic) BirdSightingDataController *dataController;
    - (IBAction)done:(UIStoryboardSegue *)segue;
    - (IBAction)cancel:(UIStoryboardSegue *)segue;
    @end
    

    的.m

    #import "BirdsMasterViewController.h"
    
    #import "BirdsDetailViewController.h"
    #import "BirdSightingDataController.h"
    #import "BirdSighting.h"
    #import "AddSightingViewController.h"
    
    @implementation BirdsMasterViewController
    
    - (void)awakeFromNib
    {
        [super awakeFromNib];
        self.dataController = [[BirdSightingDataController alloc] init];
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.navigationItem.rightBarButtonItem.accessibilityHint = @"Adds a new bird sighting event";
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    #pragma mark - Table View
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [self.dataController countOfList];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        static NSString *CellIdentifier = @"BirdSightingCell";
    
        static NSDateFormatter *formatter = nil;
        if (formatter == nil) {
            formatter = [[NSDateFormatter alloc] init];
            [formatter setDateStyle:NSDateFormatterMediumStyle];
        }
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        BirdSighting *sightingAtIndex = [self.dataController objectInListAtIndex:indexPath.row];
        [[cell textLabel] setText:sightingAtIndex.name];
        [[cell detailTextLabel] setText:[formatter stringFromDate:(NSDate *)sightingAtIndex.date]];
        return cell;
    }
    
    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // Return NO if you do not want the specified item to be editable.
        return NO;
    }
    
    - (IBAction)done:(UIStoryboardSegue *)segue
    {
        if ([[segue identifier] isEqualToString:@"ReturnInput"]) {
    
            AddSightingViewController *addController = [segue sourceViewController];
            if (addController.birdSighting) {
                [self.dataController addBirdSightingWithSighting:addController.birdSighting];
                [[self tableView] reloadData];
            }
            [self dismissViewControllerAnimated:YES completion:NULL];
        }
    }
    - (IBAction)cancel:(UIStoryboardSegue *)segue
    {
        if ([[segue identifier] isEqualToString:@"CancelInput"]) {
            [self dismissViewControllerAnimated:YES completion:NULL];
        }
    }
    
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([[segue identifier] isEqualToString:@"ShowSightingDetails"]) {
            BirdsDetailViewController *detailViewController = [segue destinationViewController];
    
            detailViewController.sighting = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
        }
    }
    
    @end
    

0 个答案:

没有答案