Tag: cocoa触摸

UIScrollView上的setContentOffset是正确的

我使用这段代码来滚动我的UIScrollView ,因为我从底部添加了一个新的UIView ,我想向下滚动。 我这样做: CGPoint newOffset = CGPointMake(mainScrollView.contentOffset.x, mainScrollView.contentOffset.y + floorf(bottomAttachmentView.frame.size.height / bottomAttachmentView.multFactor)); [mainScrollView setContentOffset:newOffset animated:YES]; 我基本上把我的新元素的高度添加到UIScrollView的contentOffset的y ,但有时它滚动scrollView的contentSize ,更低,可以滚动。 发生这种情况是因为我在调用上述方法之前修改了contentSize ,滚动视图的高度缩小了。 你怎么调用setContentOffset所以它不会让我scrollView滚动它自己的contentSize ? 谢谢!

在iPad上的UIInterfaceOrientation期间更改UIViews

我正在尝试改变旋转的观点,因为我的观点必须从纵向到横向显着不同。 现在,我正在使用的代码工作一次,然后应用程序冻结时试图回旋。 无论哪个方向都没有什么区别。 例如:如果我在景观和旋转肖像一切都很好,直到我旋转回景观,然后冻结,没有任何东西。 这是我用来实现这个的代码 在我的“viewDidLoad”方法 [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 然后我把这个叫做轮换: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; } – (void)didRotate:(NSNotification *)notification { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; if ((orientation == UIDeviceOrientationLandscapeLeft) || (orientation == UIDeviceOrientationLandscapeLeft)) { // present the other viewController, it's only viewable […]

ReactiveCocoa 4:如何在不中断信号的情况下向观察者发送错误

let (signal, sink) = Signal<[CLBeacon], BeaconManagerError>.pipe() 当我打电话给这个,因为用户禁用了蓝牙: sendError(self.sink, error) Signal中断,再次启用蓝牙后,我不会收到更多的next事件,也不会interrupted事件。 Signal坏了。 如何在不中断/打破Signal情况下将errortypes发送给observer ? 我在RAC 4文档中找不到。 谢谢!

在Cocos2d中,多层次的button,我怎样控制哪个button对用户的触摸做出反应?

现在我有一个游戏的CCLayer ,有几个button。 我想popup一个对话框,其中也有几个button。 我怎样才能closures背景button,只激活前景button?

无法将types'CFString'的值转换为期望的参数types'UnsafePointer <Void>'(又名'UnsafePointer <()>')

当我定义行时,出现构build错误 let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName) 错误是:无法将types'CFString'的值转换为期望的参数types'UnsafePointer'(又名'UnsafePointer <()>')

UIImagePickerController:检查返回的图像是横向还是纵向?

所以,UIImagePickerController不支持横向。 但是,有一部分应用程序必须将来自控制器的图像识别为纵向或横向格式。 使用UIImagePickerController从我的库中导入图像时,我可以处理这个问题。 我只是比较UIImage的宽度和高度。 但是,当我使用UIImagePickerController捕获图像时,此function将无法正常工作。 有一些额外的信息,UIImagePickerController可以提供给我,以确定它是否在横向模式中捕捉? 有没有一种创造性的方式来模拟这个function来捕捉使用UIImagePickerController的照片?

iOS版。 通过IP在同一本地networking中获取其他设备/计算机名称

我的程序的一项任务是扫描本地Wi-Finetworking,以查找同一networking中的任何设备/计算机。 我find解决scheme来获得所有工作设备的IP,但没有设法得到他们的名字。 我没有find任何线索来解决这个问题。 有什么build议么?

将标签链接到IBOutlet会提供NSUnknownKeyException

我创build了一个TabBarView。 在其中的一个选项卡上,我有一个视图上有几个Labels 。 它工作正常。 当我将界面生成器中的标签连接到文件的所有者(相应的IBOutlets)时,当我打开该标签时,应用程序崩溃并出现以下错误: 2011-05-15 18:36:29.070 AeroNav[958:707] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x18afe0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key speedLabel.' *** Call stack at first throw: ( 0 CoreFoundation 0x312a664f __exceptionPreprocess + 114 1 libobjc.A.dylib 0x34a07c5d objc_exception_throw + 24 2 CoreFoundation 0x312a63cd -[NSException dealloc] […]

在目标动作UIbutton中从多个动作中移除“一个”动作

[_btt1 addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside]; [_btt1 addTarget:self action:@selector(clicked2:) forControlEvents:UIControlEventTouchUpInside]; 在_btt1中有两个动作。 2013-05-31 10:33:31.300 testTargetAndSelector[6029:c07] actions : ( "clicked:", "clicked2:" ) 我删除clicked2这样的行动。 [_btt1 removeTarget:self action:@selector(clicked2:) forControlEvents:UIControlEventTouchUpInside]; 但_btt1中没有任何操作。 2013-05-31 10:33:32.731 testTargetAndSelector[6029:c07] actions : (null) 如何从多个操作中删除单个操作?

如何将委托函数转换为IBAction函数

我有一个委托函数更改UITableViewCell的节点位置: //On cell tap, expand func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { if indexPath.section == 0 { let data = firstDataSource[indexPath.row] tableView.beginUpdates() secondDataSource.append(data) firstDataSource.removeAtIndex(indexPath.row) let newIndexPath = NSIndexPath(forRow: find(secondDataSource, data)!, inSection: 1) tableView.moveRowAtIndexPath(indexPath, toIndexPath: newIndexPath) tableView.endUpdates() } else if indexPath.section == 1 { let data = secondDataSource[indexPath.row] tableView.beginUpdates() firstDataSource.append(data) secondDataSource.removeAtIndex(indexPath.row) let newIndexPath = NSIndexPath(forRow: find(firstDataSource, […]