有一个观点来获得ios 7中的麦克风音量?
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 0], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
NSError *error;
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];
if (recorder) {
//recorder.delegate = self;
[recorder prepareToRecord];
recorder.meteringEnabled = TRUE;
[recorder record];
levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];
} else {
NSLog(@"");// mic error message
}
- (void)levelTimerCallback:(NSTimer *)timer {
[recorder updateMeters];
const double …
Run Code Online (Sandbox Code Playgroud) 我想使用stringWithFormat将字符串附加到单个varilable中.我在使用stringByAppendingString时知道它.请帮我使用stringWithFormat为下面的代码添加.
NSString* curl = @"https://invoices?ticket=";
curl = [curl stringByAppendingString:self.ticket];
curl = [curl stringByAppendingString:@"&apikey=bfc9c6ddeea9d75345cd"];
curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""];
Run Code Online (Sandbox Code Playgroud)
谢谢,Madan Mohan.
我有一个黑色的UILabel;
我正在编写以下代码来获取黑色的组件.
UIColor *aColor = [aLabel.textColor retain];
const CGFloat* components = CGColorGetComponents(aColor.CGColor);
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
Run Code Online (Sandbox Code Playgroud)
但这总是给出绿色成分而不是黑色成分;
有人对此有所了解吗?
我通过不同的色彩空间吗?
:-( 请帮我.
我在UITableView的底部添加了一个新项目,在插入项目后,我希望UITableView滚动到最底部以显示新插入的项目.新项目保存到Core Data,UITableView使用NSFetchedResultsController自动更新.
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
switch (type) {
case NSFetchedResultsChangeInsert:
NSLog(@"*** controllerDidChangeObject - NSFetchedResultsChangeInsert");
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
//THIS IS THE CODE THAT DOESN'T WORK
[self.tableView scrollToRowAtIndexPath:newIndexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
break;
....
}
Run Code Online (Sandbox Code Playgroud)
这导致出界错误,我似乎无法使其工作.我可以通过调整索引路径的行来滚动到第二个到最后一个注释,但我无法到达最后一个项目.
基本上,我在评论表中添加注释,在添加评论后,我希望表格滚动到最新评论.
我想把设施放在显示用户选择的两个地方之间的距离.
是否有可用的示例源代码/服务?
提前致谢.
我需要写一些数字:1> yek
123> yeksad o bist o se
1,123> yek hezar o yeksad o bist o se
3,002,001> se milion o do hezar o yek ...
我,在目标c的初学者:)
我用c写它但我想把它转换成obj_c!我怎样才能做到这一点?
像这样的东西:
const char *yekan[10]={"","yek","do","se","chahar","panj","shesh","haft","hasht","noh"};
char ary[9]={'0','0','0','0','0','0','0','0','0'};
// get a number from user & converting it to string
// user number: 123 > the number in ary:000 000 123)
// '3' => 3
m=(int) ary[8];
m=m-'0';
if (j==3) { printf(" %s ",yekan[m]);} // yekan[3] = se
output: se
Run Code Online (Sandbox Code Playgroud)
谢谢.
使用gdb调试C++程序有哪些你最喜欢的技巧?
对所有技巧感兴趣但也
如何在gdb中调用对象上的方法(可能是虚拟的)
检查STL对象(漂亮打印它们)
使用continue防止gdb进入STL代码
处理内联,线程,tcmalloc(或自定义分配器)
在不同的会话中保留gdb命令的历史记录
我无法实现ADBannerView及其委托协议.
我在我的视图类中实现了以下代码(也使视图符合ADBannerViewDelegate协议):
//add iAds
ADBannerView *adView = [[ADBannerView alloc] initWithFrame: CGRectMake(0, 318, 320, 50)];
adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
adView.delegate = self;
//adView.delegate = ADBannerViewDelegate;
[self.view addSubview: adView];
Run Code Online (Sandbox Code Playgroud)
然后我为ADBannerViewDelegate创建了一个类,其中包含以下.m
//
// ADBannerViewDelegate.m
//
#import "ADBannerViewDelegate.h"
@implementation ADBannerViewDelegate
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"bannerview did not receive any banner due to %@", error);}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner{NSLog(@"bannerview was selected");}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave{return willLeave;}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {NSLog(@"banner was loaded");}
@end
Run Code Online (Sandbox Code Playgroud)
最终会显示横幅,但控制台会继续抛出以下类型的错误:
2011-02-27 15:00:54.108 app[31639:207] ADBannerView: Unhandled error (no delegate …
Run Code Online (Sandbox Code Playgroud) 我正在学习如何编码,感谢您对这个简单问题的耐心等待.
这是我的代码:
- (IBAction)buttonWasPressed:(id)sender {
NSString *buttonName = [sender titleForState:UIControlStateNormal];
if (buttonName == @"Button 1") {
do something
}
Run Code Online (Sandbox Code Playgroud)
如何将作为发送方传递的按钮的标题与字符串进行比较?
非常感谢你的帮助.
我们的应用程序具有基于地图和GPS的位置跟踪功能 此应用已在Apple Store上传.该应用程序包含以下功能:
用户的GPS位置跟踪应用程序适用于iOS版本5和6.我们在应用程序中运行Map功能时面临iOS 7 Beta的崩溃问题.我们使用iOS的以下功能在地图上呈现交通数据和交通事件:
MKAnnotation用于渲染交通事件
要呈现流量数据,应用程序正在使用CGBitmapContextCreate函数.
context = CGBitmapContextCreate (NULL,
self.mapView.frame.size.width,
self.mapView.frame.size.height,
8,// bits per component
bitmapBytesPerRow,
colorSpace,
kCGImageAlphaPremultipliedLast);
CGContextSetAllowsAntialiasing (context,YES)
Run Code Online (Sandbox Code Playgroud)绘制线以在Bitmap上下文中显示流量数据.
创建的位图上下文将使用MKAnnotation API显示在地图上.
应用程序使用NSOperationQueue呈现流量和事件数据,因为用户与地图的交互是平滑的.以下是代码片段:
[queue addOperationWithBlock:^{ [Set the required data], [Update the UI] }];
Run Code Online (Sandbox Code Playgroud)以下是两个崩溃日志,它们在Map功能的随机操作n中生成.
崩溃日志 - 1
事件
Identifier: 471EAE21-E118-4E3D-AAAE-D7D82B1D6326
CrashReporter
Key:
bdbf75eb30240449214769478f38830aa7a14f7f
Hardware
Model: iPhone5,2
Process: {Application Name} [246]
Path: /var/mobile/Applications/4FA0A7F2-4998-4F8F-A4C6-66D849D074B8/{Application Name}.app/{Application Name}
Identifier: {Application bunald name}
Version: X.X.X.X
Code
Type: ARM (Native)
Parent
Process: launchd [1]
Date/Time: 2013-08-30 14:21:24.523 +0530
OS
Version: iOS …
Run Code Online (Sandbox Code Playgroud) iphone ×5
objective-c ×4
ios ×3
ios7 ×2
append ×1
c++ ×1
cgcolor ×1
cgcolorspace ×1
cocoa ×1
cocoa-touch ×1
debugging ×1
distance ×1
gdb ×1
iad ×1
location ×1
string ×1
uitableview ×1
volume ×1