Tag: iphone

旋转固定位置的UILabel

编辑询问Autolayout是否有助于这种情况? 如何让我的UILabel在屏幕上保持固定位置但仍然可以旋转? shouldAutorotateToInterfaceOrientation返回YES并且标签旋转正常,但无论我如何在Xcode中设置弹簧,弹簧标签的位置都会发生变化。 第一张图显示了我如何在故事板中创建布局,其中包含四个单独的UILabel。 第二张图片显示了景观是如何出现的 – 而不是我想要的。 第三张图片展示了我希望如何看待风景,每个数字的旋转动画都以数字本身为中心。

iOS:在特定时间调用方法

我试图在这个时间调用一个方法: 00:01 AM : 00:01 AM这是我的代码,但我找不到为什么这段代码不调用我的方法的问题。 – (BOOL)date:(NSDate *)date hour:(NSInteger)h minute:(NSInteger)m { NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:currentCalendar]; NSDateComponents *componets = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit )fromDate:[NSDate date]]; if ([componets hour ] == h && [componets minute] == m) { return YES; } return NO; } – (void)updateNewDate { if ([self date:[NSDate date] hour:4 minute:49]) { label.text […]

我如何知道文本是否超出文本视图的范围?

我想知道文本何时超出UITextView的界限并要求用户滚动。 知道某个字体将占用多少行是没用的 – 我怎么知道一定数量的文本会占用多少行? 在上图中,我将添加淡入淡出效果,以便我可以优雅地剪切文本视图。 但是,如果没有要滚动的文本,则显示淡入淡出效果看起来不正确。

如何更改rootviewcontroller

我想在authenticationViewController之后更改rootViewController -(IBAction)LoginButtonPushed:(id)sender { if ([(VerifyId)isEqual:@”C”]){ CondidatsViewController *condidatsViewController = [[[CondidatsViewController alloc]initWithNibName:@”CondidatsViewController” bundle:nil]autorelease]; UINavigationController *navController = self.navigationController; NSMutableArray *controllers = [[self.navigationController.viewControllers mutableCopy] autorelease]; [controllers removeLastObject]; navController.viewControllers = controllers; [navController pushViewController:condidatsViewController animated: YES]; } else { RecruteursViewController *recruteursViewController = [[[RecruteursViewController alloc]initWithNibName:@”RecruteursViewController” bundle:nil]autorelease]; UINavigationController *navController = self.navigationController; NSMutableArray *controllers = [[self.navigationController.viewControllers mutableCopy] autorelease]; [controllers removeLastObject]; navController.viewControllers = controllers; [navController […]

为什么UIMenuItem动作的发送者总是为零?

我已经向UIMenuItem添加了一个UIMenuItem实例。 当我在文本字段中点击两次时,我在维基百科中获得了复制,剪切,粘贴,查找的文本编辑菜单。 这是我的行动方法: – (void)lookupInWikipedia:(id)sender { NSLog(%@”lookupInWikipedia: sender=%@”, sender); } 当我选择“在维基百科中查找”菜单项时,我得到了NSLog 。 但发件人总是零。 甚至-canPerformAction:withSender:方法也不会为发件人接收除nil之外的任何内容。 – (BOOL)canPerformAction:(SEL)action withSender:(id)sender { NSLog(@”canPerformAction:withSender: = %@”, sender); return YES; } 我做错了什么或这是一个知道框架错误?

如何在我的项目中使用一些C ++文件而不将每个文件编译为C ++?

我有一个带有基本视图控制器类的项目,它由大约25个其他视图控制器inheritance。 现在我需要在该基类中使用一些核心音频,因此我正在集成一个使用C ++的Audio类(改编自Apple的aurioTouch示例项目)。 基类导入Audio类的头,然后初始化一个Audio对象,以便我可以调用Audio类中的方法。 当我编译时,我在Audio类及其辅助类中得到“expected’=’,’,’,’;’,’asm’或’ attribute ‘之前的’!=’token”之类的错误,因为编译器正在跳闸通过C ++语法。 如果我将基类的扩展名更改为.mm,我会得到相同的错误; 我想我还必须改变从基类inheritance的所有类的扩展。 有没有办法避免这种情况? 换句话说,如何只编译最少量的文件作为C ++ – 理想情况下只是Audio类,Audio类和基类 – 而不更改项目的其余部分? 我问的原因是这一点音频大约是应用程序function的0.5%,并且改变几十个文件进行不同编译似乎是错误的,因为这只是一个小小的补充。

改变iOS音频播放器的音高 – 像Alvin和花栗鼠

我在StackOverflow中找到了这段代码片段。 我认为这就是我想要使用的。 但我不能让它改变音调 – 就像我预期的那样。 我认为改变44100.0上/下会影响音高。 但无论setValue如何,我都没有变化。 NSMutableDictionary *settings = [[NSMutableArray alloc] init]; [settings setValue: [NSNumber numberWithFloat:44100.0] forKey:AVSampleRate]; 显然我错过了一些东西。 任何额外的片段可以提供更多的上下文?

设置UILabel背景颜色会导致应用崩溃

我有以下代码: UIImageView *photo = [[[UIImageView alloc] initWithFrame:CGRectMake(title_bar.titleView.frame.origin.x+130, title_bar.titleView.frame.origin.y-12, 22.0, 22.0)] autorelease]; UIImage *theImage = [UIImage imageNamed:@”question mark icon”]; photo.image = theImage; UIView *new_view = [[UIView alloc] init]; [new_view addSubview:photo]; UILabel *new_label = [[UILabel alloc] initWithFrame:CGRectMake(title_bar.titleView.frame.origin.x-145, title_bar.titleView.frame.origin.y-12, 268.0, 22.0)]; [new_label setText:@”gregrgtg”]; [new_label setBackgroundColor:[UIColor clearColor]]; //COMMENTING THIS LINE OUT MAKES IT WORK [new_view addSubview:new_label]; title_bar.titleView = new_view; […]

关于gamecenter + ios的问题

我对gamecentre一无所知。我正在研究COCO应用程序,我已经通过游戏中心指南,并能够将游戏中心集成到我的应用程序中。 1) 现在我可以通过我的应用程序输入游戏中心的分数。 通过做这个:- – (void) reportScore: (int64_t) score forCategory: (NSString*) category { GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease]; scoreReporter.value = score; [scoreReporter reportScoreWithCompletionHandler: ^(NSError *error) { [self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error]; }]; } 我昨天正在努力工作。但是现在如果我试图更新分数它没有更新。请任何人知道分数没有在游戏中心更新的原因我试图搜索但没有得到任何东西。 2)我想将一个玩家的当前纬度和经度发送到另一个玩家。 我开始知道GKMATCH有可能 GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; request.minPlayers = 1; request.maxPlayers = 1; [[GKMatchmaker sharedMatchmaker] […]

从iPhone App访问现有语音备忘录

我希望我现在的iPhone App可以访问iPhone以获取现有的语音备忘录。 两个问题: 默认情况下,iPhone上的语音备忘录存储。 我是否可以从我的iPhone应用程序访问Audio Recorder(Voice Momos)应用程序。 我可以从iPhone应用程序访问这些语音备忘录吗? (如果没有,那么是否有任何参考资料提供相同的证据,我没有那个访问权限?)