我试图通过indexOfObject方法获取数组的索引,如下所示,但当我尝试记录该值以测试索引时,我得到一个垃圾值..为了测试目的,我有一个数组的值,{57,56,58..}以获得索引让我们说56,
NSNumber *num = [NSNumber numberWithInteger:56];
NSInteger Aindex = [myArray indexOfObject:num];
NSLog(@" %d",Aindex);
Run Code Online (Sandbox Code Playgroud)
我得到的价值就像2323421.我可能做错了什么?
我试图通过的属性设置来显示用户的当前位置MKMapView 即setShowsUserLocation到YES.默认情况下,当应用程序开始更新用户位置时,iPhone屏幕左上方会出现一个箭头.但是在显示当前位置后,箭头应该消失,但只要应用程序正在运行,它仍然存在,这意味着应用程序仍处于静止状态在后台更新位置?那我怎么能停止更新当前位置?我已经实现了立即调用的委托..
我试图通过以下方式检测两个精灵的碰撞 ...但是当我尝试运行游戏时没有发生碰撞......我可能做错了什么?
- (void)update:(ccTime)dt {
CGRect projectileRect = CGRectMake(projectile.position.x - (projectile.contentSize.width/2),
projectile.position.y - (projectile.contentSize.height/2),
projectile.contentSize.width,
projectile.contentSize.height);
//CGRectMake(0,220,320,50);
CGRect targetRects = CGRectMake(_monkey.position.x - (_monkey.contentSize.width/2),
_monkey.position.y - (_monkey.contentSize.height/2),
_monkey.contentSize.width,
_monkey.contentSize.height);
if (CGRectIntersectsRect(projectileRect, targetRects)) {
NSLog(@"ha ha Collision detected");
}
Run Code Online (Sandbox Code Playgroud)
}
射弹精灵从屏幕顶部到底部动画,猴子精灵在底部动画从底部向右射弹穿过猴子,但日志不会被称为???
- (void)update:(ccTime)dt {
CGRect projectileRect = [projectile boundingBox];
CGRect targetRects = [_monkey boundingBox];
if (CGRectIntersectsRect(projectileRect, targetRects))
{
NSLog(@"ha ha Collision detected");
}
CGRect projectileRects = CGRectMake(projectile.position.x - (projectile.contentSize.width/2),
projectile.position.y - (projectile.contentSize.height/2),
projectile.contentSize.width,
projectile.contentSize.height);
CGRect targetRect = …Run Code Online (Sandbox Code Playgroud) 我试图使用AssetsLibrary框架在以下代码的帮助下访问iPhone库中的视频...但是当我运行应用程序代码不能正常...数组资产仍然是空的?我究竟做错了什么??
顺便说一句,我的iPhone是3G升级到iPhone 4.1.(但资产框架没有给出任何错误)
NSMutableArray *assets = [[NSMutableArray alloc]init];
ALAssetsLibrary *library =[[ALAssetsLibrary alloc]init];
void (^assetEnumerator)(struct ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != NULL) {
NSLog(@"See Asset: %@", result);
[assets addObject:result];
}
};
void (^assetGroupEnumerator)(struct ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil) {NSLog(@"dont See Asset: ");
[group enumerateAssetsUsingBlock:assetEnumerator];
}
};
assets = [[NSMutableArray alloc] init];
library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"Failure"); …Run Code Online (Sandbox Code Playgroud) 我试图在MPMovieplayer的帮助下播放一个Url的视频,它将它加载到Quicktime播放器中,而我希望视频只在我的应用程序中播放(没有后台模式)?我怎么能实现那个?将在UIWebview中播放视频而不是MPMoviePlayer工作?此外,当QuickTime播放器仅加载音频播放时,没有显示视频?我使用以下代码
NSString *videoFilepath = @"http://www.migital.com/Hemant/1.3gp";
NSURL *videoURL = [NSURL URLWithString:videoFilepath ];
MPMoviePlayerViewController *movie = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movie];
[self presentMoviePlayerViewControllerAnimated:movie];
Run Code Online (Sandbox Code Playgroud) 我正在开发一个应用程序,我正在尝试使用AVCaptureSession类录制视频...我遇到了一些像这样的好教程
http://www.benjaminloulier.com/posts/2-ios4-and-direct-access-to-the-camera
但是在这些教程中,只有从视频帧中捕获图像才能完成,而我想要录制一个全长视频,我可以将其保存在我的设备中或上传到我的服务器....如何使用AVFoundation框架实现这一目标?
我正在开发一个小型游戏,我在UIWebview中集成广告.由于UIKit对象在将其添加到Cocos2d层时遇到困难.它很简单,可以将它添加到一个层,但Webview需要时间来加载.同时当我移动到其他类时,UIWebview加载并添加到该特定的CCLayer类,在我使用的同一个类中删除它们
[webViewH stopLoading];
[webViewF stopLoading];
webViewF.hidden=YES;
webViewH.hidden=YES;
[webViewH removeFromSuperview];
[webViewF removeFromSuperview];
Run Code Online (Sandbox Code Playgroud)
但是一旦我移动到另一个类给NSZombieEnabled - Webview:didCommitLoadForFrame或者有时Webview:didclearwindowObject,我的应用程序就会被杀死.我猜它仍然在前一课中加载,而我已经从superview中删除了所以app被杀了?我可能做错了什么?
好的,所以我想检测用户在iOS设备中启用热点/网络共享的天气.我可以使用私人api知道它不会进入应用程序商店.
我试图通过私人api的列表/运行时标题,但有太多,无法决定哪些可能有用.
或者我是否可以知道UIApplicationWillChangeStatusBarFrameNotification在私有api中被触发的位置(可能需要调用活动调用和激活的热点等)
我试过检测个人热点并使用CaptiveNetwork,但它只返回连接的wi-fi ssid而不是创建的热点.
任何分享的知识都会非常有帮助
更新:@creker
使用上面的代码,编译器显示错误"SCDynamicStoreCreate不可用:在iOS上不可用.所以我进入SCDynamicStore.h并更改了以下内容
SCDynamicStoreRef
SCDynamicStoreCreate (
CFAllocatorRef allocator,
CFStringRef name,
SCDynamicStoreCallBack callout,
SCDynamicStoreContext *context
) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA);
Run Code Online (Sandbox Code Playgroud)
至
SCDynamicStoreRef
SCDynamicStoreCreate (
CFAllocatorRef allocator,
CFStringRef name,
SCDynamicStoreCallBack callout,
SCDynamicStoreContext *context
) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_6_0);
Run Code Online (Sandbox Code Playgroud)
现在我能够获得状态1022和1023的字典.只是想通过更改这样的文件来确认(以前没做过)我将在归档构建(或任何其他问题)中存在任何问题,除此之外我们的事实知道这段代码不会进入应用程序商店
由于iPhone 4现在具有640X960分辨率,我很困惑如何为320 X 480和640 X 960分辨率构建适当的UI ..如果我只使用图像和640X960分辨率的东西,它会自动调整自己适用于较小分辨率的iPhone ..如果不是什么是基于设备分辨率区分的最佳方法?
我有一个数组的最后两个CGPoints,其中包含用户绘制的线条.我需要以相同的角度将线延伸到固定的距离.所以我首先在下面的代码的帮助下计算最后两点之间的角度
-(CGFloat)angleBetweenFirstPoint:(CGPoint)firstPoint ToSecondPoint:(CGPoint)secondPoint
{
CGPoint diff = ccpSub(secondPoint, firstPoint);
NSLog(@"difference point %f , %f",diff.x,diff.y);
CGFloat res = atan2(diff.y, diff.x);
/*if ( res < 0 )
{
res = (0.5 * M_PI) + res;
}
if ( dx<0 && dy>0 ) { // 2nd quadrant
res += 0.5 * M_PI;
} else if ( dx<0 && dy<0 ) { // 3rd quadrant
res += M_PI;
} else if ( dx>0 && …Run Code Online (Sandbox Code Playgroud) iphone ×8
ios ×6
ios4 ×5
avfoundation ×1
mapkit ×1
math ×1
nsarray ×1
resolution ×1
tethering ×1
uiwebview ×1