? 在Xcode 6 beta 6中没有名为“下标”的成员

在屏幕上显示时,我使用了下面几行代码来获取键盘的框架。 我已经注册到UIKeyboardDidShowNotification通知。 func keyboardWasShown(notification: NSNotification) { var info = notification.userInfo var keyboardFrame: CGRect = info.objectForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue() } 这曾经工作在testing版5.我下载了最新的Xcode 6版本,这是beta 6,这个错误发生在第二行。 '[NSObject:AnyObject]?' 没有名为'objectForKey'的成员 谷歌search后,我遇到了这个解决scheme。 我改变了它, var keyboardFrame: CGRect = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue() 但现在看来也是过时了。 因为我现在得到这个错误。 '[NSObject:AnyObject]?' 没有名为“下标”的成员 我不知道这个错误或如何解决它。

Swift 3与iOS兼容

我是苹果开发新手,很快我会通过AppStore分发我的应用程序。 所以现在我正在使用Swift 3,默认情况下,部署目标设置为iOS 10.0。这意味着我将无法在iOS 8-9上运行它。 在Swift 3中,我使用了以后的操作系统中没有的新的funcs

如何将UIAppearance Proxy属性应用于UILabel?

在尝试将UIAppearance代理样式应用于UILabel类代理时,我一直得到不可靠的结果。 例如,下面的工作,我期望: [[UILabel appearance] setFont:[UIFont fontWithName:SOME_FONT size:SOME_SIZE]]; [[UILabel appearance] setShadowColor:[UIColor blackColor]]; 设置textColor不起作用,但是,这: [[UILabel appearance] setColor:[UIColor greenColor]]; 确实有效 那种 。 这是有点不可靠的,并导致任何特定于实例的调用setTextColor:被忽略。 将UIA外观样式应用于UILabel的正确方法是什么?

在UILabel / UITextView中获取单词

我想要做的是创build一个文本容器组件,它能够指示什么是最接近的单词,当它有一个触摸(即单词“触摸点”后面)。 首先,我创build了一个UILabel子类,并覆盖了touchesEnded:withEvent:方法来确定所触及的CGPoint。 我还写了一个方法,使用sizeWithFont:forWidth:lineBreakMode:来计算文本的每个单词的相应“框架”(CGRect)。 用触摸的CGPoint和这个框架,我可以确定哪个单词实际上被触摸。 但是计算框架的方法只适用于单行文本。 所以现在我需要知道文本的哪一部分在给定的行上(即文本是如何被分割的),以便我能够确定每个单词的正确的左边距和上边距。 任何想法如何我可以得到这个? 或者,也许你有一个更直接的解决scheme来实现这一目标? 这个post不幸的是不是很有帮助… …

UICollectionView将图像添加到单元格

我正在使用UICollectionView来显示可能有或没有图像的数据的项目。 我使用的方式是检查图像的URL不是null,然后将一个ImageView添加到单元格。 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { if (question.picture != (id)[NSNull null]) { //add AsyncImageView to cell imageView.contentMode = UIViewContentModeScaleAspectFill; imageView.clipsToBounds = YES; imageView.tag = IMAGE_VIEW_TAG; [cell addSubview:imageView]; [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; imageView.imageURL = [NSURL URLWithString:question.picture]; } } 对于那些没有图像的单元格,单元格应该如下所示: https : //dl.dropboxusercontent.com/u/5753236/Stackoverflow/good.png 但是,他们中的一些仍然会添加一个带有裁剪图像的ImageView,导致如下所示: https : //dl.dropboxusercontent.com/u/5753236/Stackoverflow/bad.png 我试过使用SDWebImage,但仍然没有解决问题。 另一个问题是当我向下滚动UICollectionView ,会看到一些图像显示为上面显示的图像,然后在加载完成后切换到正确的图像,我不知道是什么导致了问题。 请帮我解决这两个问题,我真的很感激任何帮助。

将子视图控制器添加到当前视图控制器

我试图通过使用下一个代码添加一个子视图控制器的代码,从故事板到当前的视图控制器: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init]; lvc = (LogInTutorialViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LogInTutorialViewControllerID"]; [self displayContentController:lvc]; – (void) displayContentController: (LogInTutorialViewController*) content; { //add as childViewController [self addChildViewController:content]; [content didMoveToParentViewController:self]; [content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; [self.view addSubview:content.view]; } 视图似乎至less在模拟器上显示,但在控制台我得到很多或错误: <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. […]

在Swift中将hexstring转换为NSData

我得到了在Objective-C中将string转换为HEX-String的代码。 – (NSString *) CreateDataWithHexString:(NSString*)inputString { NSUInteger inLength = [inputString length]; unichar *inCharacters = alloca(sizeof(unichar) * inLength); [inputString getCharacters:inCharacters range:NSMakeRange(0, inLength)]; UInt8 *outBytes = malloc(sizeof(UInt8) * ((inLength / 2) + 1)); NSInteger i, o = 0; UInt8 outByte = 0; for (i = 0; i < inLength; i++) { UInt8 c = inCharacters[i]; SInt8 value […]

.NET的unit testing运行器

有没有人写过(或了解).netunit testing运行器, 在 NUnit上运行的优先级? 还是我必须推出自己的? 我的目标是在模拟器或设备上执行unit testing。 到目前为止,我已经看到了嘲讽monotouch.dll(但在PC上运行testing)的一些post/博客和一个答案,指出缺乏这样的工具。

NSTimer timerWithTimeInterval:不工作

在我的项目中实现它之前,我用计时器创build了一个testing应用程序。 这是我第一次使用计时器。 但问题是,当我使用[NSTimer timerWithTimeInterval: target: selector: userInfo: repeats: ];实现了计时器[NSTimer timerWithTimeInterval: target: selector: userInfo: repeats: ]; ,它不工作。 这是我的代码,接口: @interface uialertViewController : UIViewController { NSTimer *timer; } -(void)displayAlert; -(void)hideandview; @end 执行: @implementation uialertViewController – (void)viewDidLoad { [self displayAlert]; [super viewDidLoad]; } -(void)displayAlert{ timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(hideandview) userInfo:nil repeats:NO]; alert = [[UIAlertView alloc] initWithTitle:@"testing" message:@"hi hi […]

在iOS5中使用Twitter框架提示login提醒?

大家可能知道,由于iOS5有一个原生的Twitter框架,可以很容易地从你的应用程序发布推文。 有没有办法提示提醒用户转到设置应用程序并要求input用户名和密码? 我知道我可以用下面的代码解决问题: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]]; 但那是没有文件的代码.. 提前致谢 关心比利(我的第一篇文章)