Tag: cocoa touch

无法使用内部使用.xib文件的iOS框架

我正在尝试通过以下URL中指定的步骤为iOS创build通用框架: Universal-framework-iOS 我有一个viewController类,内部加载.xib文件的框架。 下面是代码的一部分,它显示了我如何初始化viewController并显示相关视图: /*** Part of implementation of SomeViewController class, which is outside the framework ***/ – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.viewControllerWithinFramework = [[ViewControllerWithinFramework alloc] initWithTitle:@"My custom view"]; } – (IBAction)showSomeView:(id)sender { [self.viewControllerWithinFramework showRelatedView]; } /*** Part of implementation of ViewControllerWithinFramework […]

无限的UIScrollView

我想实现一个时间轴,就像你可以在iMovie或Final Cut中find的一样,你可以向任何一个方向滚动。 滚动到左侧会回到时间(月),滚动到右侧会及时前进,创build一个平稳的继续path。 什么是实施这个最好的方法? 用UIScrollView做一些棘手的事情 子类UIView并尝试重新创build惯性滚动 重新创build惯性滚动的缺点是,如果苹果决定改变它,我的应用程序会感到奇怪。 我个人不喜欢它,当一个应用程序没有感觉系统集成,这包括像塔疯狂的游戏,他们使自己的滚动视图工作非常糟糕,感觉不对。

什么时候应该使用__bridge与CFBridgingRelease / CFBridgingRetain?

我有这个代码使用“__bridge”来投射颜色的ID: CGColorRef tabColor = (5 == 5 ? [UIColor blueColor].CGColor : [UIColor greenColor].CGColor); CGColorRef startColor = [UIColor whiteColor].CGColor; CGColorRef endColor = tabColor; NSArray *colors = [NSArray arrayWithObjects:(__bridge id)startColor, (__bridge id)endColor, nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)colors, locations); 但会: NSArray *colors = [NSArray arrayWithObjects:(id)CFBridgingRelease(startColor), (id)CFBridgingRelease(endColor), nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)CFBridgingRetain(colors), locations); 成为更好的解决scheme?

iOS 9 supportedInterfaceOrientations不起作用

我有一个UIViewController与下面的代码: – (BOOL) shouldAutorotate { return NO; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationPortrait; } 我没有使用UINavigationController 。 当这个UIViewController被显示时,设备仍然会旋转到横向。 我针对iOS 9,这里有什么问题?

UIFont fontWithName返回nil

在我的info.plist中,我添加了一个键“应用程序提供的字体”,并添加了EdwardianScriptITCStd.otf 但是,当我尝试获取该字体时,返回nil: NSLog(@"%@", [UIFont fontWithName:@"EdwardianScriptITCStd" size:16.0f]); 我使用[UIFont familyNames]打印字体系列,但它也不存在: ( Thonburi, "Snell Roundhand", "Academy Engraved LET", "Marker Felt", "Geeza Pro", "Arial Rounded MT Bold", "Trebuchet MS", Arial, Marion, "Gurmukhi MN", "Malayalam Sangam MN", "Bradley Hand", "Kannada Sangam MN", "Bodoni 72 Oldstyle", Cochin, "Sinhala Sangam MN", "Hiragino Kaku Gothic ProN", Papyrus, Verdana, "Zapf Dingbats", Courier, "Hoefler Text", […]

iOS应用程序的操作队列与调度队列

Operation Queue和Dispatch Queue有什么区别? 在什么情况下使用它们会更合适?

带图像和标题的UISegmentedControl

我正在使用一个UIToolBar内的UISegmentedControl作为button。 我不能使用正常的UIButtonBarItem ,因为我需要设置tintColor并支持iOS 4.3。 所以我使用下面的代码: UISegmentedControl* searchButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"", nil]]; [searchButton setImage:[UIImage imageNamed:@"search_picto"] forSegmentAtIndex:0]; searchButton.momentary = YES; searchButton.segmentedControlStyle = UISegmentedControlStyleBar; searchButton.tintColor = [UIColor colorWithRed:0.27 green:0.60 blue:0.20 alpha:1.00]; [searchButton addTarget:self action:@selector(actionSearch:) forControlEvents:UIControlEventValueChanged]; 这很好,但有没有一种方法可以在我的图像旁边显示文本/标题? 方法setTitle:删除图像。 必须有另一种方式 谢谢你的帮助。 – 编辑:我决定直接添加文本到UIImageView像这样: NSString* label = @"My Label"; UIImage* image = [self addText:label toImage:[UIImage imageNamed:@"icon"]]; [_segmentedControl insertSegmentWithImage:image atIndex:0 […]

iOS应用程序中没有CATiledLayer的巨大图像?

我有一个约7000×6000像素的图像。 我需要这个在我的应用程序中的scrollview / imageView,但是这是巨大的方式来显示。 它应该是一种地图。 我希望能够将应用程序的大小保持在最低限度,图像大小约为13mb。 在PNG是超过100MB,这是不能接受的。 许多人build议CATiledLayer作为一个选项,但我相信这将导致更大的文件大小。 无论如何,我试图用CATiledLayer ,并在TileCutter中创build我自己的瓷砖,(瓷砖以.jpg为单位),尺寸不是太差。 但是我到处都有错误。 CATiledLayer的iOS版本对我来说是一个谜,我找不到解决这个问题的方法。 我得到一个错误,说有关java的等价“索引超出数组的界限”,即使该数组有内容在该特定的索引..它有一个方法返回一个数组。 该数组包含.plist的数据。 在返回之前,我注销了数组的内容,给了我很好的数据。 电话正试图访问 [array objectAtIndex:0] 并把它放在一个字典,但抛出OutOfBounds。 注销整个数组时,我可以清楚地看到内容,但是在注销时 NSLog("%@",[method objectAtIndex]); I get the same exception. 无论如何, CATiledLayer给了我一些问题。 我一直在逆向工程的PhotoScroller项目没有运气。 任何人都有其他的解决scheme 谢谢。

设置一个背景图像/视图来生活相机视图?

是否可以为特定的视图控制器设置背景以显示实时相机视图? 如果是这样的话,是否可以引导我朝正确的方向发展呢?

我可以访问文件系统上的xcassets目录吗?

我想dynamic加载一个xcassets目录中的所有图像。 这些文件被命名为StockPhoto#,其中#是列表中的数字。 如果我可以在运行时访问我的StockPhotos.xcassets以统计目录中的所有文件,那么每次添加新的库存照片时都不必手动加载文件。 如果还有其他的解决scheme,我可以这么做,但是我也很好奇xcassets是如何被文件系统处理的 – 不pipe它们是只是引用了一组文件,还是实际上是它们自己的目录。 有关这方面的信息是稀疏的。