简体   繁体   English

在iPad Simulator上可用,但在iPad上崩溃

[英]Works on iPad Simulator but crashes on iPad

Hi I am trying to develop a new app on the ipad. 嗨,我正在尝试在ipad上开发一个新应用。 I am using a spitTableView and adding a ModalPresentationPage to the view. 我正在使用spitTableView并将ModalPresentationPage添加到视图中。 This works perfectly on the xcode iPad sim but crashes on my iPad. 这在xcode iPad sim上完美运行,但在我的iPad上崩溃。 just so you know I am using xcode 5BATA and running IOS 5 on my iPad. 如此您就知道我正在使用xcode 5BATA并在iPad上运行IOS 5。

here is my code 这是我的代码

DetailViewController.h DetailViewController.h

#import <UIKit/UIKit.h>

@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>{

}

-(IBAction)loadView:(id)sender;

@property (strong, nonatomic) id detailItem;

@property (strong, nonatomic) IBOutlet UILabel *detailDescriptionLabel;

@property (strong, nonatomic) IBOutlet UIToolbar *toolbar;

@end

DetailViewController.m DetailViewController.m

#import "DetailViewController.h"
#import "ModalViewController.h"
#import "RootViewController.h"

@interface DetailViewController ()
@property (strong, nonatomic) UIPopoverController *popoverController;
- (void)configureView;
@end

@implementation DetailViewController


@synthesize detailItem = _detailItem;
@synthesize detailDescriptionLabel = _detailDescriptionLabel;
@synthesize toolbar = _toolbar;
@synthesize popoverController = _myPopoverController;



-(IBAction)loadView:(id)sender{
    ModalViewController *mvc = [[ModalViewController alloc]initWithNibName:@"modalViewController"bundle:nil];
    mvc.modalPresentationStyle = UIModalPresentationPageSheet;
    mvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:mvc animated:YES];
}

- (id)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
    }
    return self;
}

#pragma mark - Managing the detail item

- (void)setDetailItem:(id)newDetailItem
{
    if (_detailItem != newDetailItem) {
        _detailItem = newDetailItem;

        // Update the view.
        [self configureView];
    }

    if (self.popoverController != nil) {
        [self.popoverController dismissPopoverAnimated:YES];
    }        
}

- (void)configureView
{
    // Update the user interface for the detail item.

    if (self.detailItem) {
        self.detailDescriptionLabel.text = [self.detailItem description];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self configureView];
    self.splitViewController.delegate = self;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

#pragma mark - Split view

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc
{
    barButtonItem.title = @"Master";
    NSMutableArray *items = [[self.toolbar items] mutableCopy];
    [items insertObject:barButtonItem atIndex:0];
    [self.toolbar setItems:items animated:YES];
    self.popoverController = pc;
}

- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
    // Called when the view is shown again in the split view, invalidating the button and popover controller.
    NSMutableArray *items = [[self.toolbar items] mutableCopy];
    [items removeObjectAtIndex:0];
    [self.toolbar setItems:items animated:YES];
    self.popoverController = nil;
}

@end

Parts not under NDA :- 不属于NDA的零件:

  1. You are leaking items in both the split view delegate methods. 您正在两个拆分视图委托方法中泄漏items
  2. Are you sure the XIB name is modalViewController ? 您确定XIB名称是modalViewController吗? There could a problem of it being case sensitive on the device. 可能存在设备区分大小写的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM