小编Geo*_*bin的帖子

如何在iOS中为numpad键盘添加"完成"按钮

因此,numpad键盘默认没有"完成"或"下一步"按钮,所以我想添加一个.在iOS 6及更低版本中,有一些技巧可以在键盘上添加一个按钮,但它们似乎不适用于iOS 7.

首先,我订阅显示通知的键盘

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(keyboardWillShow:)
                                             name:UIKeyboardWillShowNotification
                                           object:nil];
Run Code Online (Sandbox Code Playgroud)

然后我尝试在键盘出现时添加一个按钮:

- (void)keyboardWillShow:(NSNotification *)note 
{
    // create custom button
    UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeSystem];
    doneButton.frame = CGRectMake(0, 50, 106, 53);
    doneButton.adjustsImageWhenHighlighted = NO;
    [doneButton setTitle:@"Done" forState:UIControlStateNormal];
    [doneButton addTarget:self action:@selector(dismissKeyboard) forControlEvents:UIControlEventTouchUpInside];

    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) 
    {
        keyboard = [tempWindow.subviews objectAtIndex:i];
        // keyboard view found; add the custom button to it
        if([[keyboard description] hasPrefix:@"UIKeyboard"] == YES)
        [keyboard addSubview:doneButton]; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch uitextfield uikit ios

83
推荐指数
4
解决办法
7万
查看次数

如何在Xcode中更改鼠标的i-beam光标?

当我在xcode 5.0.2中进行编码时,我使用深色背景,也许我只是变老,但是当将鼠标悬停在文本上时,很难看到光标.

我尝试了这个问题的解决方案: 在Xcode 4中更改鼠标的i-beam光标

但不幸的是它没有效果.

有什么建议?

ide xcode cursor

4
推荐指数
1
解决办法
4131
查看次数

监控可可触摸中的当前dB级别(iPhone)

所以基本上我只想监视iPhone中麦克风(s?)拾取的当前dB级别,主要是客观的c代码.我在谷歌上环顾四周,看起来你需要用AudioQueues进行一些"硬核"编程才能让它运转起来.我不擅长C编码所以下面的代码是我尝试使用最低限度的C编码来获得一个结果,我可以将其发送回我热情和熟悉的Objective-c土地.问题是,我似乎无法创建AudioQueue,我得到的'状态'是-50,这是'未知错误'.

我本质上是在我的viewDidLoad中设置音频队列并在其上面声明交流回调,并且在回调中我抓住当前的dB值并将其发送回目标c,但回调永远不会被调用,因为AudioQueue不是正确创造,我不明白为什么.任何人都能看到我做错的事情,或者指出我对这个音频内容的客观c包装的方向.干杯.

@interface ViewController ()
{
    AudioQueueRef mQueue;
}

- (void)receivedSoundOfPower:(Float32)power;

@end

@implementation ViewController


void MyInputBufferHandler(  void *                              inUserData,
                                      AudioQueueRef                     inAQ,
                                      AudioQueueBufferRef                   inBuffer,
                                      const AudioTimeStamp *                inStartTime,
                                      UInt32                                inNumPackets,
                                      const AudioStreamPacketDescription*   inPacketDesc)
{
    ViewController *self = (__bridge id)inUserData;

    AudioQueueLevelMeterState meters[1];
    UInt32 dlen = sizeof(meters);
    OSStatus status = AudioQueueGetProperty(inAQ,kAudioQueueProperty_CurrentLevelMeterDB,meters,&dlen);
    if (status == 0)
    {
        Float32 peakPower = meters[0].mPeakPower;
        [self receivedSoundOfPower:peakPower];
    }
}

- (void)receivedSoundOfPower:(Float32)power
{
    NSLog(@"%f", power);
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    OSStatus status =AudioQueueNewInput(kAudioStreamAnyRate,
                                MyInputBufferHandler,
                                (__bridge void *)(self),
                                NULL, …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c

1
推荐指数
1
解决办法
1900
查看次数

标签 统计

cocoa-touch ×2

cursor ×1

ide ×1

ios ×1

iphone ×1

objective-c ×1

uikit ×1

uitextfield ×1

xcode ×1