小编Sim*_*e99的帖子

使用transitionFromViewController在UIViewControllers之间自定义动画:toViewController:duration

我试图使用UIViewController的transitionFromViewController:toViewController:duration方法,但使用自定义动画.

我有以下两个视图控制器作为子项添加到自定义容器UIViewController:

  1. firstController - 这是UITabBarController的一个实例
  2. secondController - 这是UIViewController的子类

以下代码按预期工作:

[self transitionFromViewController:firstController
                  toViewController:secondController 
                          duration:2                                         
                           options:UIViewAnimationOptionTransitionFlipFromLeft  
                        animations:^(void){} 
                        completion:^(BOOL finished){}];
Run Code Online (Sandbox Code Playgroud)

但是,我想创建一个自定义动画,其中firstController向左secondController滑动,并从右侧滑入替换,类似于UINavigationControllers推送和弹出方法的工作方式.更改后options,UIViewAnimationOptionTransitionNone我试图在animations块中实现自定义动画,但绝对没有成功. firstController立即交换secondController没有动画和动画.

我真的很感激任何帮助.

谢谢

objective-c ios5

7
推荐指数
1
解决办法
6592
查看次数

NSSortDescriptors中的块 - 目标C.

我有一个switch创造相关的声明NSSortDescriptor.对于一些NSSortDescriptors我使用的block作为自定义comparator(比较CMTimes).以下代码工作正常,但我想添加一些NSSortDescriptors比较CMTimes.由于block总是相同的是可以创建一个variable来保持,block所以我不需要继续复制和粘贴杂乱的代码.我想它应该是可能的,但我似乎无法让它发挥作用.我非常感谢任何帮助.谢谢!

NSSortDescriptor *sortDescriptor; 

switch (mode) {
    case 1:
        sortDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"startTime" ascending: YES comparator:^(id first, id second){
                    CMTime time1 = [first CMTimeValue];
                    CMTime time2 = [second CMTimeValue];
                    if (CMTIME_COMPARE_INLINE(time1, <, time2)) 
                        return NSOrderedAscending;
                    else if (CMTIME_COMPARE_INLINE(time1, >, time2))
                        return NSOrderedDescending;
                    else
                        return NSOrderedSame;
        }];
        break;
    case 2:
        sortDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"startTime" ascending: NO comparator:^(id first, …
Run Code Online (Sandbox Code Playgroud)

macos objective-c nssortdescriptor ios

3
推荐指数
1
解决办法
5106
查看次数

在iOS电子书阅读器中使用execCommand突出显示HTML的任何替代方法

我正在为iOS开发一个图书阅读器UIWebView.目前我正在使用一些基本的HTML文件,但最终将与ePubs一起使用.我正在寻找一种合适的文本范围样式.我的范围有点特殊,因为它们通常包含三个范围 - 一个键范围和一个范围,紧接在之前和范围之后.键范围可以跨越多个节点,并且可以例如在粗体文本等的选择内开始或结束.不应将样式写入文件.

目前我有一个工作解决方案如下:

document.designMode = "on";

// Color the first section
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range1);

if (!selection.isCollapsed){ 
document.execCommand("foreColor", false, color1);    
}

// Color the middle section
selection.removeAllRanges();
selection.addRange(range2);

if (!selection.isCollapsed){   
document.execCommand("backColor", false, color2);
document.execCommand("foreColor", false, color3);
}

// Color the last section
selection.removeAllRanges();
selection.addRange(range3);

if (!selection.isCollapsed){ 
document.execCommand("foreColor", false, color1);
}

document.designMode = "off";
selection.removeAllRanges();
Run Code Online (Sandbox Code Playgroud)

这工作正常但速度明显很慢(在iPad2上),即使我修改它以突出显示短HTML文档中的单个范围.在文本风格化之前总是有非常明显的延迟.看看iPad上的电子书阅读器,如kindle或iBooks,没有明显的延迟.他们如何实现突出显示功能?他们可能正在阅读所选文本的地理位置并应用某种叠加?

我已经找到了比我已经使用的更好的解决方案,但没有运气,所以如果有人有想法我会非常感激.

谢谢!

javascript highlighting uiwebview ios

2
推荐指数
1
解决办法
2905
查看次数