我正在构建一个使用UISplitViewController用于iPad的通用应用程序,并且应该可以在任何3.0设备上工作,例如第一代iPhone/iPod touch.麻烦的是,尽管我在iPhone上运行应用程序时实际上并没有创建任何UISplitViewController实例,但我仍然感到害怕
dyld: Symbol not found: _OBJC_CLASS_$_UISplitViewController
Referenced from: /var/mobile/Applications/.....
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
Run Code Online (Sandbox Code Playgroud)
试图在第一代iPod touch上运行时控制台出错.但是在iOS 4设备上一切正常.我猜测问题是我已经将UISplitViewController子类化了,并且当从.h文件中读取"@interface SplitControl:UISplitViewController {"行时它会发出扼流圈.
我将其子类化的唯一原因是覆盖shouldAutorotateToInterfaceOrientation方法.我正在以编程方式完成我的整个应用程序而没有IB.如果我使用IB创建SplitViewController并告诉它支持所有方向,它会有帮助吗?
有没有办法覆盖shouldAutorotateToInterfaceOrientation而无需继承控制器?从3.2之前的设备隐藏UISplitViewController的任何其他方法?
我有一个非常痛苦的慢脚本,从MySQL获取大量数据并创建一个大型报告,它最终作为应用程序/强制下载服务于用户.
长话短说,在生产服务器上它会在大约30秒后(非常一致地)终止并且吐出一个空文件.在开发服务器上它工作正常,但执行时间要长得多 - 大约90秒.为了'安全',我将我的php.ini文件设置为max_execution_time = 2000
并set_time_limit(4000)
在脚本的开头运行(数字超过预期的完成时间,但只是为了确保;)).
什么可能导致我的网络服务器忽略我设置的时间限制并在30秒后退出我?
编辑:我确定知道的一件事是它需要8-9秒的MySQL部分代码才能完成,并且每次都成功地超过了这一点.
我想引用具有特定类型的枚举对象,而不仅仅是泛型AnyObject!
,但在文档中找不到有关它的任何信息.
enumerateObjectsUsingBlock
Swift中的签名是:
func enumerateObjectsUsingBlock(_ block: ((AnyObject!,
Int,
UnsafePointer<ObjCBool>) -> Void)!)
Run Code Online (Sandbox Code Playgroud)
在目标C中:
- (void)enumerateObjectsUsingBlock:(void (^)(id obj,
NSUInteger idx,
BOOL *stop))block
Run Code Online (Sandbox Code Playgroud)
如果我想将迭代的对象视为特定类型,则在Objective CI中只需动态调整签名,例如:
[array enumerateObjectsUsingBlock:^(NSString *s, NSUInteger idx, BOOL *stop){
// ...some function of s as NSString, not just id...
}];
Run Code Online (Sandbox Code Playgroud)
如何在Swift中获得此行为?
简而言之,我想检测导航控制器标题栏上的触摸,但实际上却无法触及任何触摸!
如果这有所不同,一切都在没有IB的情况下完成.
我的app delegate的.m文件包含:
MyViewController *viewController = [[MyViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:navigationController.view];
Run Code Online (Sandbox Code Playgroud)
此窗口中添加了一些其他子视图,其方式是覆盖navigationController,只留下导航栏可见.
MyViewController是UIViewController的子类,其.m文件包含:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
NSLog(@"ended\n");
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
NSLog(@"began\n");
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试将这些函数直接放入app delegate的.m文件中,但控制台仍为空白.
我究竟做错了什么?
假设我有一个非常长的文件utilities.php,它包含Web应用程序使用的大部分功能(如果不是全部).每个加载的页面都包含()这个文件,但可能只使用其中的少数几个函数.
以这种方式做事有明显的缺点,表现明智吗?我可以根据提供的功能类型将文件拆分成几个,但严格地从性能角度来看,将所有内容都包含在每个页面中是不好的,但只运行所需的内容?
在我的应用程序的绘图部分,用户应该能够选择他们创建的路径。UIBezierPath
有一个方便的方法containsPoint:
,在大多数情况下效果很好,但是当绘制的线接近没有曲线的直线时,它会特别糟糕。让你的手指碰到一条直线是非常困难的。
该方法似乎只检查路径上很窄的一条线,即使将lineWidth
路径的属性设置为较大的值也不会影响containsPoint:
测试结果。
我看过类似的问题,比如这个:检测 UIBezierPath 笔触上的触摸,不是填充但无法修改解决方案以查看“路径周围的区域”,它似乎只查看中心的细线其中。
编辑
我提出的一个有效但密集的解决方案是将路径转换为 aUIImage
并在请求的点检查该图像的颜色。如果 alpha 分量大于零,则路径与触摸相交。
这看起来像这样:
// pv is a view that contains our path as a property
// touchPoint is a CGPoint signifying the location of the touch
PathView *ghostPathView = [[PathView alloc] initWithFrame:pv.bounds];
ghostPathView.path = [pv.path copy]; // make a copy of the path
// 40 px is about thick enough to touch reliably
ghostPathView.path.lineWidth = 40;
// the two magic …
Run Code Online (Sandbox Code Playgroud)