我正试图窥探/使用非故事板Objective-C项目,我不断获得白色背景而不是模糊背景。我试过模拟器和我的iPhone。
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location{
if ([self.presentedViewController isKindOfClass:[LoadTreatmentDetailViewController class]]) {
return nil;
}
NSIndexPath *indexPath = [self.loadTreatmentsTableView indexPathForRowAtPoint:location];
if(indexPath){
AllTreatmentsTableViewCell *tableCell = [self.loadTreatmentsTableView cellForRowAtIndexPath:indexPath];
if(tableCell.treatment){
LoadTreatmentDetailViewController *previewController = [[LoadTreatmentDetailViewController alloc] initWithTreatment:tableCell.treatment withContext:self.context];
if(previewController){
previewController.preferredContentSize = CGSizeMake(0.0, 0.0);
previewingContext.sourceRect = tableCell.frame;
return previewController;
}
}
}
return nil;
}
- (void)previewingContext:(id<UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit{
[self presentViewController:viewControllerToCommit animated:YES completion:nil];
}
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
if([self isForceTouchAvailable]){
if(!self.previewingContext){
self.previewingContext = [self registerForPreviewingWithDelegate:self sourceView:self.view];
}
}else{
if(self.previewingContext){
[self unregisterForPreviewingWithContext:self.previewingContext];
self.previewingContext = nil;
}
}
}
- (BOOL)isForceTouchAvailable {
BOOL isForceTouchAvailable = NO;
if([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]){
isForceTouchAvailable = self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable;
}
return isForceTouchAvailable;
}
有可能吗?
感谢您的帮助!
答案 0 :(得分:0)
这是我用于Scrollview的UIApperance。