0

好的,我很难过......所有与缺少插座相关的答案都指向确保插座已连接。我已经确定它是。您可以在下面的屏幕截图中看到它。问题是代码运行在IOS5.0。所以这绝对是一些与兼容性相关的问题。我也尝试了两个答案中的建议。但这无济于事。

这是调用 xib 的代码。有什么线索吗?感谢您的帮助。

- (id) initWithModuleDataDict:(id)dataObject andStepNumber:(int)stepNumber
{
    if ((self = [super initWithNibName:@"PhoneContent" bundle:nil])) {
        self.moduleData = (NSDictionary *)dataObject;
        self.module = [self.moduleData objectForKey:kModuleClassKey];
        numberOfSteps = [[self.module steps] count];
        self.doShowMeasurementViews = self.module.doShowMeasurementViews;

        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.automaticallyAdjustsScrollViewInsets = NO;

        // view controllers are created lazily in the loadScrollViewWithPage: method...
        // in the meantime, load the array with placeholders which will be replaced on demand
        NSMutableArray *controllers = [[NSMutableArray alloc] init];
        for (unsigned i = 0; i < numberOfSteps; i++)
        {
            [controllers addObject:[NSNull null]];
        }
        self.viewControllers = controllers;

        //        CGRect fullScreenRect = [[UIScreen mainScreen] applicationFrame];
        CGRect fullScreenRect = CGRectMake(0, 0, 320, 372);
        UIScrollView *theScrollView = [[UIScrollView alloc] initWithFrame:fullScreenRect];
        self.scrollView = theScrollView;
        [theScrollView release];
        CGRect bottomRect = CGRectMake(0, 410, 320, 20);
        UIPageControl *thePageControl = [[UIPageControl alloc] initWithFrame:bottomRect];
        thePageControl.center = CGPointMake(160.0, 400.0);
        self.pageControl = thePageControl;
        [thePageControl release];


        // a page is the width of the scroll view
        scrollView.pagingEnabled = YES;
        scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * numberOfSteps, scrollView.frame.size.height);
        scrollView.showsHorizontalScrollIndicator = NO;
        scrollView.showsVerticalScrollIndicator = NO;
        scrollView.scrollsToTop = NO;
        scrollView.delegate = self;
        scrollView.decelerationRate = UIScrollViewDecelerationRateFast; //shp

        pageControl.numberOfPages = numberOfSteps;
        pageControl.currentPage = stepNumber;

        // Create the transition sound
        // Create the url for the source audio file (URLForResource:withExtension: method is new in 4.0)
        NSURL *purrSound = [[NSBundle mainBundle]URLForResource:@"purr" 
                                                  withExtension:@"aiff"];
        // Store the url as a CFURLRef instance
        self.soundFileURLRef = (CFURLRef)[purrSound retain];    
        // Create a system sound object representing the sound file
        AudioServicesCreateSystemSoundID(soundFileURLRef, &soundFileObject);

        [controllers release];

    }
    return self;
}

在此处输入图像描述 在此处输入图像描述

4

2 回答 2

0

我在将旧的 xib 移植和升级到新的 Xcode 时有过不同的经历。我在这些情况下所做的只是创建一个新的 xib 文件并从旧文件复制并粘贴控件。然后我重新分配超类并重新映射代表。

我希望我有一个更好的解决方案,但这对我有用。

此外,如果您在之前的 XCode 项目中没有使用 AutoLayout,请留意 Xcode 5 中的它有点不同。

于 2013-09-26T21:08:40.157 回答
0

请在您的代码中添加此逻辑。

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
   // Load resources for iOS 6.1 or earlier
} else {
   // Load resources for iOS 7 or later
}

并仔细阅读此文档。

于 2013-09-27T05:47:00.377 回答