好吧,我很难过......所有与缺失相关的答案都指向确保插座连接。我已经确定它是。您可以在下面的屏幕截图中看到它。问题是代码在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;
}
答案 0 :(得分:0)
我有把旧xib移植和升级到新Xcode的混合经验。 我在这些实例中所做的只是创建一个新的xib文件,并从旧版本复制并粘贴控件。然后我重新分配超类并重新映射代表。
我希望我有更好的解决方案,但这对我有用。
另外,如果您在之前的XCode项目中没有使用AutoLayout,请注意Xcode 5中的相似内容。
答案 1 :(得分:0)
请在您的代码中添加此逻辑。
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
仔细阅读doc。