草庐IT

Objective-c

全部标签

objective-c - 是否可以使用 presentMoviePlayerViewControllerAnimated 播放多个剪辑?

我有一种情况,我想使用使用presentMoviePlayerViewControllerAnimated显示的MPMoviePlayerViewController连续播放2个视频剪辑。问题是模态视图会在第一部电影播放完毕后自动关闭。有没有人找到办法做到这一点? 最佳答案 三个选项:您可以使用MPMoviePlayerController并在第一个项目完成后开始播放第二个(第N个)项目。然而,这将在视频之间引入一个小间隙,这是由内容的识别和预缓冲引起的。你可以使用AVQueuePlayer;AVQueuePlayer是AVPlay

ios - 如何在不被打扰的情况下在后台循环播放声音?

以下代码应循环播放无声音频剪辑,以保持应用程序在后台处于事件状态://setsessions.............//playaudio_player=[[AVAudioPlayeralloc]initWithContentsOfURL:urlerror:NULL];audio_player.numberOfLoops=-1;//alwaysrepeatboolret=[audio_playerplay];您按下主页按钮,它会在后台播放,使您的应用程序保持事件状态。但是,当您调用电话时,播放器会停止并且[audio_playerplay]之后会返回false。那么问题来了,在后台的

objective-c - 为什么我第二次按下 View 时后退按钮没有出现?

每次单击图片时,我都会调用此方法(将View推送到详细View):-(IBAction)loadTeamView:(id)sender{teamView=[[TeamViewControlleralloc]initWithNibName:@"TeamViewController"bundle:nildetailItem:self.detailItem];[self.navigationControllerpushViewController:teamViewanimated:YES];}它有效,但如果您单击后退按钮(自动出现)然后返回此方法,则不会显示后退按钮。有什么想法吗?

objective-c - 如何在 XCode 4.2 中更改模型中不同 Controller 的数据

我对Objective-C和iOS编程还很陌生,我在传递数据时遇到了很多麻烦。我创建了一个模型“LevelsCompleted”,我在其中声明了一个NSString属性:@property(readwrite,copy)NSString*answersString;我在.m文件中合成了:@synthesizeanswersString=_answersString;现在,如果我在我的一个Controller中更改它的值-(void)changeAnswersString{LevelsCompleted*lvls=[[LevelsCompletedalloc]init];[lvlsset

objective-c - 使用对象填充 NSMutableSet 不起作用 - NSLog 和调试器显示 Null

我正在尝试使用NSMutableSet创建一组对象。对象是一个标签,每个标签都有一个id和一个名字。标签类定义如下:#import"Tag.h"@implementationTag@synthesizeid,name;+(id)populateTagObjectWithId:(NSString*)idandName:(NSString*)name{Tag*myTag=[[selfalloc]init];myTag.id=id;myTag.name=name;returnmyTag;}...remainderofcodesnippedout在我的应用程序的其他地方,我使用SQLite来获

iphone - 在 iPhone 上解码 HTML 实体

我有一个包含多个位置的列表,其中一些包含字母æ、Æ、ø、Ø、å和Å。从我正在使用的网络服务中,这些字母显示为“ø”“&戒指;”等等当我从网络服务下载提要时,我使用UTF-8编码。如何解码这些字符的出现?谢谢! 最佳答案 没有标准的方法可以简单地编写您自己的自定义方法(或NSString扩展)并执行此操作:string=[stringstringByReplacingOccurrencesOfString:@"&"withString:@"&"]; 关于iphone-

objective-c - objective c singleton dispatch_once 实现更好?

看到很多人建议用dispatch_once来做单例:+(MyClass*)singleton{staticdispatch_once_tpred;staticMyClass*shared=nil;dispatch_once(&pred,^{shared=[[MyClassalloc]init];});returnshared;}当它并不真正支持真正的单例时为什么会更好,而且人们仍然可以使用init创建实例甚至在sharedInstance上进行发布?Apple的方法是防止所有这些情况http://developer.apple.com/library/mac/#documentatio

objective-c - PresentModalViewController 与导航 Controller 中的推送 View 具有相同的动画?

是否可以将PresentModalViewController与使用导航Controller的“pushViewController”方法时显示的相同动画一起使用? 最佳答案 据我所知,它不能水平移动。而且,当您使用presentModalViewController:animated:时,之前的View将消失(空白)。但是你可以这样做(将你想要的View添加到你的窗口的顶部):UIViewController*modalViewController=[[UIViewControlleralloc]init];[modalViewC

objective-c - 使用 UIControl(特别是 UIButton)时如何对目标进行排序?

在我的应用程序中,我有多个UIButtons我为其添加了目标。事实证明,最近添加的目标首先被执行,然后是剩余的目标。例如,拿这段代码:[buttonaddTarget:selfaction:@selector(someAction:)forControlEvents:UIControlEventTouchUpInside];[buttonaddTarget:selfaction:@selector(someOtherAction:)forControlEvents:UIControlEventTouchUpInside];如果我在button内部进行修饰,someOtherAction

iphone - 设置 UITableViewCell :textLabel:text 时应用程序崩溃

我正在创建一个SplitViewiPad应用程序。当用户按下主视图中的条形按钮项时,将显示一个模式。这个模式有一个文本字段和一个IBAction来获取键盘返回。在键盘返回时,我的Farm类的一个新实例被创建(代码如下)。然后将此实例添加到存储在我的委托(delegate)中的数组中。然后我尝试重新加载MasterViewController的表。重新加载后,应用程序在cell.textLabel.text上崩溃并出现EXC_BAD_ACCESS错误。Farm*current=[delegate.arrayOfFarmsobjectAtIndex:indexPath.row];cell.