Tag: 目标C

DontDestroyOnLoad – 如何摧毁?

我正在研究Vuforia (遗留)应用程序。 在Unity的“播放”模式下,我可以看到正在生成一些“DontDestroyOnLoad”内容 (看起来像是一个相机)。 这可能是为什么我在切换场景时遇到一些问题的原因,所以问题是如何使这些元素“可销毁” ?

Objective C使用C ++ POSIX类的项目

我必须使用一些C ++ POSIX类的代码创build一个iOS程序。 我已经阅读了Apple开发人员中心的“使用Objective-C的C ++”手册。 他们描述了如何在.mm文件中混合C ++和Objective C代码。 我的问题是,有没有可能在正常的Objective C项目的.h / .m文件中使用C ++类? 或者是否有必要写在整个项目中.mm文件样式与自己的主?

UITableView – IndexPath总是返回0,并且需要2次点击才能将正确的数据传递给视图控制器

我有一个UITableViewinheritance了ViewController 。 我的tableview包含位置名称列表,当您select一个位置时,它会将更详细的数据传递给视图控制器关于选定的位置。 我的问题是,我的索引path始终返回0在第一次点击/加载无论我点击哪一行。 我必须点击每一行两次传递正确的数据。 例如:我点击row2>返回row1的(0)数据。 然后再次单击row2>正确返回row2的数据>然后单击row3>返回row2的数据>我必须再次单击row3才能获取row3的数据。 在下面的代码中selectindexPathSelected始终为0 。 NSInteger indexPathSelected; – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { indexPathSelected = indexPath.row; } #pragma mark – Navigation – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showLocationDetails"]) { LocationDetailsViewController *vc = [segue destinationViewController]; vc.location = _locationsArray [indexPathSelected]; } }

如何在iOS中对有符号数组进行sorting?

这可能是一个简单的问题,但我不知道如何对有符号整数值进行sorting。 我的数组在sorting之前, pointsAry (-2,-7,-5,0,-3,2,-1,-4,1,3,-6) 使用后 NSArray * sortedArray = [pointsAry sortedArrayUsingComparator:^(id str1, id str2){ return [(NSString *)str1 compare:(NSString *)str2 options:NSNumericSearch]; }]; 结果 sortedArray : (-1,-2,-3,-4,-5,-6,-7,0,1,2,3) 对于有符号值sortedArray格式不正确,所以我需要 (-7,-6,-5,-4,-3,-2,-1,0,1,2,3) 如何sorting像上面的格式? 提前致谢。

GridView中的UIAccessibility – 没有看到新的单元格

在我的项目中我有tableView,作为一个行有一个自定义的UITableViewCell,它有一个属性 – GMGridView(它类似于UICollectionView),它有它的委托方法: – (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index { GMGridViewCell *cell = [gridView dequeueReusableCell]; if (!cell) { cell = [[GMGridViewCell alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)]; cell.contentView = [[GridViewContentView alloc] initWithFrame:cell.frame style:GridViewStyleNews]; } Item *feed = _contentArray[index]; GridViewContentView *contentView = (GridViewContentView *)cell.contentView; contentView.textLabel.text = feed.textLabel; [contentView.imageView setURL:[NSURL URLWithString:feed.imageLink] withPreset:self.preset]; cell.contentView = contentView; NSLog(@"Address index %d – […]

在iOS设备上找不到文件Qt Creator C ++ QStandardPaths :: standardLocations(QStandardPaths :: DownloadLo cation);

我正在使用Qt Creator C ++ QStandardPaths :: standardLocations(QStandardPaths :: DownloadLo阳离子); 到达用户的文件,但不会返回在iOS设备上find的文件。 这是我的代码到目前为止: const QStringList mPathList = QStandardPaths::standardLocations(QStandardPaths::DownloadLo‌​cation); mPath = QString("%1").arg(mPathList.first()); dirmodel = new QFileSystemModel (this); dirmodel->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); dirmodel->setRootPath(mPath);

如何并行执行多个callback方法

我在集成Web服务时使用callback方法。 任何人都可以build议,我怎么可以并行使用多个callback方法, 我知道我们可以通过创build来集成多个Web服务 dispatch_group_t group = dispatch_group_create(); //block 1 dispatch_group_async(group, dispatch_get_global_queue(0, 0), ^{ [self getUserProfiles]; }); //block 2 dispatch_group_notify(group, dispatch_get_global_queue(0, 0), ^{ // block 2 will get notify, after block 1 complete his task. } 但是如何执行上面的,使用callback? 任何build议将不胜感激。

无效的指针Xcode 8

我正在Xcode 8.1中开发一个应用程序。 它用于在networking中查找打印机。 它也使用cpp文件进行打印机search。 但是我得到了一个错误 malloc: *** error for object 0x6080000099f0: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug 我使僵尸赶上这个exception,但失败。我还加了malloc错误中断但失败。 添加try catch,但是它显示try块内的错误break。 请帮助我如何捕捉这个exception,如果有人已经面临这个问题,请帮助我如何解决这个问题。

自定义setter方法的委托被称为无限次

在我的VC我已经声明了一个自定义的委托属性: @interface VC2 : BaseVC @property (nonatomic,weak) id<VC2Delegate> delegate; @end 并从VC1,我设置这个代表: – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([[segue identifier] isEqualToString: @"VC2"]) { self.VC2 = [segue destinationViewController]; [self.VC2 setDelegate:self]; } } 在我的VC2中,我为代表写了一个setter方法: -(void)setDelegate:(id)del{ self.delegate=del; } 这个问题,在VC1中的pprepareForSegue方法调用之后,VC2中委托的setter方法被调用了很多次,我的应用程序崩溃了。 我不确定可能是什么原因。 这里是satcktrace: 我没有任何实现我的BaseVC。 这只是一个普通的VC。

检测圆上的触点,Cocos2d

我在cocos2d中创build了一个带有drawfunction的圆圈,我试图检测圆圈上的触点,让用户触摸我想要打印的圆圈底部270,如果用户触摸圆圈的顶部,我要打印90等。 … 我已经看过这个问题,但他们先检测一个精灵,然后比较一下,如果接触内部或外部的圆圈 http://www.cocos2d-iphone.org/forum/topic/21629 如何在圈内检测触摸 – (void) draw { CGSize winSize = [[CCDirector sharedDirector] winSize]; glLineWidth(10.0f); ccDrawColor4F(0.2f, 0.9f, 0.02f, 0.6f); CGPoint center = ccp(winSize.width*0.88, winSize.height*0.8); CGFloat radius = 100.f; CGFloat angle = 0.f; NSInteger segments = 100; BOOL drawLineToCenter = YES; ccDrawCircle(center, radius, angle, segments, drawLineToCenter); } 如何检测圆形线上的触点?