0

我在 Xcode 5 中为 iOS7 开发应用程序,但自从升级到 iOS 8 和 Xcode 6 后,我遇到了一些问题。

基本上,我使用 SWRevealViewController 为我的应用程序创建一个滑动侧边栏。该侧边栏有许多行,其中包含标签和图片。它们以前看起来很好,但现在它们如下所示:

http://postimg.org/image/4ddj5n6df/

他们都挤在一起。我还收到了几个“缺少约束”错误以及两个“可滚动内容大小”错误。

可能是 SWRevealViewController 插件没有正确升级以与 iOS 8 一起使用吗?有替代方案吗?

@interface foodforteethSidebarViewController ()
@property (nonatomic, strong) NSArray *menuItems;

@end

@implementation foodforteethSidebarViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.tableView.separatorColor = [UIColor colorWithWhite:0.4f alpha:0.2f];

    _menuItems = @[@"home", @"title", @"cereals", @"meats", @"snacks", @"dairy", @"drinks", @"desserts", @"fastfoods", @"fruitandveg", @"sauces", @"confectionaries", @"misc"];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

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

#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 [self.menuItems count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = [self.menuItems objectAtIndex:indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    return cell;
}

- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
    // Set the title of navigation bar by using the menu items
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    UINavigationController *destViewController = (UINavigationController*)segue.destinationViewController;
    destViewController.title = [[_menuItems objectAtIndex:indexPath.row] capitalizedString];

    if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] ) {
        SWRevealViewControllerSegue *swSegue = (SWRevealViewControllerSegue*) segue;

        swSegue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) {

            UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
            [navController setViewControllers: @[dvc] animated: NO ];
            [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
        };

    }

}

@end

谢谢

4

0 回答 0