Tag: xcode

以编程方式切换Swift中的选项卡

我需要编写一些代码,以便在iOS应用程序启动时将视图切换到另一个选项卡(例如,默认显示第二个选项卡,而不是第一个选项卡)。 我是新来的Swift,并已经制定了以下内容: 代码可能应该在第一个选项卡的ViewController的覆盖func viewDidLoad()函数中进行。 下面的代码显示了第二个ViewController,但不是底部的标签栏(vcOptions是第二个ViewController标签项: let vc : AnyObject! = self.storyboard.instantiateViewControllerWithIdentifier("vcOptions") self.showViewController(vc as UIViewController, sender: vc) 我想答案可能在于使用UITabbarController.selectedIndex = 1,但不太清楚如何实现这个。

如何使用twitter api v1.1获取用户详细信息(Twitter错误215)

我已经使用twitter提供的twitter API来获取详细信息,但无法执行它,甚至试图传递消费者密钥,消费者密钥,令牌等身份validation数据,但结果是一样的。 我能够login并接收Twitter身份validation令牌,但无法获取用户详细信息。 下面的代码是我使用的(我正在使用MGtwitter引擎): NSMutableURLRequest *request =[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.twitter.com/1.1/users/show.json?screen_name=%@",username]]]; NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ]; NSString *returnString = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding]; NSError *err = nil; twitterLogin = [NSJSONSerialization JSONObjectWithData:[returnString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&err]; 错误如下所示: errors = ( { code = 215; message = "Bad Authentication data"; } );

如何dynamic更改自动布局iOS中的字体大小?

我想适合我的文字在一个UILabel ,但对于不同的iPhone UILabel的大小正在改变,因为我使用自动布局,但我不能修复字体大小,所以我的文字被删除。 有什么办法可以设置任何约束,以便文本dynamic适应UILabel ? 由于不同的屏幕分辨率,在这里看到的文字被削减

录制audio文件并保存在iPhone本地

我一直在寻找这个地方的答案,但无法find我所需要的。 基本上在我的应用程序,我录制语音文件(如iOS语音备忘录应用程序),然后将其保存到本地文件目录。 由于某种原因,下次我启动应用程序时,录制文件的URL就会过期。 此外,即使没有,如果我logging两次,第二个文件的URL获得相同的URL作为第一个,所以我失去了第一个文件。 这样录制: [audioRecorder record]; 其中:AVAudioRecorder * audioRecorder; 玩是好的: [audioPlayer play]; 其中:AVAudioPlayer * audioPlayer; logging语音备忘录并将其保存到iPhone上的本地磁盘的最佳方法是什么? 谢谢。 更新: 我试图使用这个代码: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName]; BOOL status = [data writeToFile:filePath atomically:YES]; 数据是我的AVAudioPlayer NSData属性的数据,但BOOL得到0,不知道为什么。

在NSString中查找substring的所有位置(不只是第一个)

有一个string出现在一个string中多次。 我使用rangeOfString ,但似乎只能find第一个位置。 我怎样才能find子string的所有位置? NSString *subString1 = @"</content>"; NSString *subString2 = @"–\n"; NSRange range1 = [newresults rangeOfString:subString1]; NSRange range2 = [newresults rangeOfString:subString2]; int location1 = range1.location; int location2 = range2.location; NSLog(@"%i",location1); NSLog(@"%i",location2);

设置UIScrollView在3个视图控制器之间滑动

我想build立一个UIScrollView,以便我可以在3个视图控制器之间滑动。 这是我在AppDelegate.m中的代码: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch.; UIScrollView *sv = [[UIScrollView alloc] init]; BarsViewController *bvc = [[BarsViewController alloc] init]; // Create BarsViewController StopwatchViewController *svc = [[StopwatchViewController alloc] init]; // Create StopwatchViewController TimerViewController *tvc = [[TimerViewController alloc] init]; // Create […]

如何分发私人程序到100多个设备?

我在一家大公司工作,我们有企业数量。 我build立了一个私人的iPhone程序,并成功地做出了特别的企业分布。 所以我可以将程序交付到100个设备,而无需应用程序商店。 但有人对我说,我可以交付到无限数量的iPhone而不使用应用程序商店。 可能吗? 如果没有,如果我的程序将被用于超过100个iPhone手机,我该怎么办? 我有什么select?

Xcode UItesting示例

我刚刚了解了Xcode中的unit testing 。 现在我正在尝试Xcode 7,当我创build一个新项目时,我发现有一个新的UItesting组。 我观看了WWDC 2015的video ,这很不错,但是你有一个超级简单的例子,我可以通过自己? 这些video的例子对我来说太复杂了。 笔记 下面的答案是我试图弄清楚这一点,但我欢迎任何更好的答案。 我已经阅读了这些关于Xcode UItesting的问题,但它们不同: 在XCode 7项目之前 , 文档 , 重装 , App与UI , ViewController , 多个 值和属性 。

如何从挖掘位置获取CGPoint?

我正在为iPaddevise一个graphics计算器应用程序,我想添加一个function,用户可以在graphics视图中点击一个区域,使文本框popup,显示它们所触摸的点的坐标。 我怎样才能从这个CGPoint?

更改iPhone的初始屏幕时间

我如何让启动屏幕停留更长时间,例如5秒钟?