我有一个NSMutableArray,我需要搜索一个字符串并返回找到字符串的数组中的键.因此,例如,如果我正在搜索"ipod"并且它是数组中的第4个,它将返回3或字符串所处的任何位置.最好的方法是什么?
我用[NSDate date]发起了一个NSDate; 我想检查自NSDate变量以来是否已经过了5个小时.我该怎么做呢?我的代码中包含的是
requestTime = [[NSDate alloc] init];
requestTime = [NSDate date];
Run Code Online (Sandbox Code Playgroud)
在后来的方法中,我想检查自requestTime以来是否已经过了12个小时.请帮忙!提前致谢.
我正在尝试根据数组中的NSDictionary位置添加数组中的对象NSArray,但是一旦NSDictionary分配,应用程序就会崩溃.有什么想法吗?
NSString *venue_title = [venues objectAtIndex:[actionSheet tag]];
NSString *venue_address = [venues_full_address objectAtIndex:[actionSheet tag]];
NSString *venue_lat = [venues_lat objectAtIndex:[actionSheet tag]];
NSString *venue_lng = [venues_lng objectAtIndex:[actionSheet tag]];
NSLog(@"%@, %@, %@, %@", venue_title, venue_address, venue_lat, venue_lng);
NSDictionary *venue_details_dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:venue_title, venue_address, venue_lat, venue_lng, nil] forKeys:[NSArray arrayWithObjects:@"name", @"address", @"lat", "lng", nil]];
Run Code Online (Sandbox Code Playgroud)
我在NSLog对象时看到所有正确的值,但NSDictionary使应用程序崩溃并出现EXC_BAD_ACCESS错误.我NSZombies启用了,但是当它像经常显示的那样崩溃时没有显示任何内容.关于这里发生了什么的任何想法?提前致谢!
我正在编写一个考虑了服务器资源的应用程序,所以我不想使用太多,以便将来可以扩展这个应用程序.我不介意写自己的查询.那么,我的应用程序的ActiveRecord资源是否密集?或者它没有什么区别?
谢谢!
我有一个字符串,我正在转换为一个浮点数,我想检查if语句中的值.
原始浮点值是从didUpdateHeading方法返回的iPhone的trueHeading.当我使用@"%.2f"将原始浮点数转换为字符串时,它可以正常工作,但我要做的是将原始浮点数转换为相同的值.如果我只是将字符串转换为[string floatValue],我得到相同的原始浮点数,我不希望这样.
为了简化和简单,如何获取现有浮点值并获得前2位小数?
我已经在这几个小时了,甚至不知道如何调试这个错误.也许有一位SO专家知道发生了什么.
- (void) prepareSubset {
CGSize size = [image size];
float scale = fminf(1.0f, fmaxf(SUBSET_SIZE / cropRect.size.width, SUBSET_SIZE / cropRect.size.height));
CGPoint offset = CGPointMake(-cropRect.origin.x, -cropRect.origin.y);
subsetWidth = cropRect.size.width * scale;
subsetHeight = cropRect.size.height * scale;
subsetBytesPerRow = ((subsetWidth + 0xf) >> 4) << 4;
subsetData = (unsigned char *)malloc(subsetBytesPerRow * subsetHeight);
CGColorSpaceRef grayColorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef ctx = CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight, 8, subsetBytesPerRow, grayColorSpace, kCGImageAlphaNone);
CGColorSpaceRelease(grayColorSpace);
CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
CGContextSetAllowsAntialiasing(ctx, false);
CGContextTranslateCTM(ctx, 0.0, subsetHeight);
CGContextScaleCTM(ctx, 1.0, -1.0);
UIGraphicsPushContext(ctx);
CGRect rect = …Run Code Online (Sandbox Code Playgroud) 我让我的AVCaptureSession工作,它几乎完美地复制了Camera.app用户界面,然而,几秒钟后应用程序将崩溃,我只是找不到我做错了什么.我真的希望有人知道如何优化这个!
我AM使用ARC; 而且,整个会话运行良好,但稍微崩溃了.AVCaptureSession委托方法被调用似乎每秒钟.如果只有当用户按下"拍照"按钮时才有办法调用该方法,那么如何在保持"实时"预览图层的同时执行此操作?
提前致谢!
设置会话
NSError *error = nil;
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;
device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
[session addInput:input];
output = [[AVCaptureVideoDataOutput alloc] init];
[session addOutput:output];
dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
output.videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
if(version >= 4.0 && version < 5.0) {
output.minFrameDuration = CMTimeMake(1, 15);
}
output.alwaysDiscardsLateVideoFrames = YES;
previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:previewLayer];
[self.view addSubview:camera_overlay];
[session …Run Code Online (Sandbox Code Playgroud) 我有一个MKAnnotationView被分配了一个DetailDisclosure按钮显示在注释的右侧.我怎么知道用户何时点击了注释按钮?这就是我的代码现在的样子 -
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
pinView.animatesDrop = YES;
Run Code Online (Sandbox Code Playgroud)
是否有内置方法来检测附件视图何时被触摸?我猜它会像UITableView方法,但我找不到任何东西.谢谢你的帮助.
我正在构建一个应用程序,用户可以提供他/她拥有的不同用户名.愿景是,用户能够添加和删除UITableViewCell以输入用户名.
现在我有一个分组的UITableView,在每个UITableViewCell的右侧,我有一个UIButton,它使用UITextField向表中添加另一个单元格.在第一个单元格之后,每个单元格都有一个删除按钮.我正在尝试让UIButton删除该行.我有删除单元格的IBAction,唯一的问题是,它没有删除正确的行.
做我想做的事情的最佳方法是什么?我不知道如何在Google上正确搜索此内容.我敢肯定有人做了我想做的事情.
在此先感谢您的帮助!
我一直在使用这种方法将常规NSString对象转换为NSDate,但尝试向Apple提交更新并被拒绝.在iOS中执行此操作的另一种方法是什么?
NSString *date_str = @"2011-08-12T12:20:00Z";
NSDate *the_date = [NSDate dateWithNaturalLanguageString:date_str locale:[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]];
Run Code Online (Sandbox Code Playgroud)
提前致谢!
iphone ×6
objective-c ×5
ios4 ×4
xcode ×3
activerecord ×1
avcapture ×1
cgcontext ×1
codeigniter ×1
ios ×1
mapkit ×1
nsdate ×1
nsdictionary ×1
php ×1
uitableview ×1