小编8vi*_*ius的帖子

iOS - 关闭呈现为inputView的UIDatePicker

我的UI中有一个文本字段,当它被选中时会显示UIDatePicker而不是默认键盘,如何设置一个按钮,以便在用户完成时关闭选择器?

uidatepicker uitextfield ios inputview

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

iOS - 在MKAnnotationView上设置详细信息披露按钮

我的MapViewController中有以下方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
    MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
    if (!annotationView) {
        annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
        annotationView.canShowCallout = YES;
        annotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        // could put a rightCalloutAccessoryView here
    } else {
        annotationView.annotation = annotation;
        [(UIImageView *)annotationView.leftCalloutAccessoryView setImage:nil];
    }

    return annotationView;
} 
Run Code Online (Sandbox Code Playgroud)

我相信它设置正确,但是当我的地图正确地显示我的带有标题和副标题的注释时,但它们没有显示详细信息披露按钮,我错过了什么吗?

另一件事是,在调试时,从不调用此方法,但注释视图显示标题和副标题.

uibutton mapkit mkannotation mkannotationview ios

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

设置静态UITableView单元格的数据

我有一个UITableView看起来像这样:

在此输入图像描述

在第一个单元格中,我显示了一个,UIImageView如您所见,还有2个标签.文本是从代码设置的.这里没问题.

我的问题关注底部4个单元格,我想为它们动态设置数据,当我这样做时,我无法设置标签和UIImageView.我的意思是设置一切cellForRowAtIndexPath.有人可以解释我如何处理这个案子吗?

uitableview ios

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

iOS - 播放录制的音频失败,OSStatus错误-43(找不到文件)

当我的视图加载时,我按以下方式设置AVAudioRecorder实例:

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
audioSession.delegate = self;
[audioSession setActive:YES error:nil];
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil];

NSString *tempDir = NSTemporaryDirectory();
NSString *soundFilePath = [tempDir stringByAppendingPathComponent:@"sound.m4a"];

NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSLog(@"%@", soundFileURL);

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
                                [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
                                [NSNumber numberWithInt:16], AVEncoderBitRateKey,
                                [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                                [NSNumber numberWithFloat:8000.0], AVSampleRateKey,
                                [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey,
                                nil];

NSError *error = nil;

self.recorder = [[AVAudioRecorder alloc]
                 initWithURL:soundFileURL
                 settings:recordSettings
                 error:&error];
self.recorder.delegate = self;

if (error) {
    NSLog(@"error: %@", [error localizedDescription]);
} else { …
Run Code Online (Sandbox Code Playgroud)

core-audio avfoundation avaudioplayer avaudiorecorder ios

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

Beautifulsoup4与lxml对比Beautifulsoup3

我正在将一些解析器从BeautifulSoup3迁移到BeautifulSoup4,我认为分析考虑到lxml是超快的并且它是我使用BS4的解析器,这将是一个好主意,这里是配置文件结果:

对于BS3:

43208 function calls (42654 primitive calls) in 0.103 seconds

Ordered by: standard name

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    1    0.000    0.000    0.000    0.000 <string>:2(<module>)
   18    0.000    0.000    0.000    0.000 <string>:8(__new__)
    1    0.000    0.000    0.072    0.072 <string>:9(parser)
   32    0.000    0.000    0.000    0.000 BeautifulSoup.py:1012(__init__)
    1    0.000    0.000    0.000    0.000 BeautifulSoup.py:1018(buildTagMap)
... 
Run Code Online (Sandbox Code Playgroud)

对于使用lxml的BS4:

164440 function calls (163947 primitive calls) in 0.244 seconds

Ordered by: standard name

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    1    0.040    0.040    0.069    0.069 <string>:2(<module>)
   18    0.000 …
Run Code Online (Sandbox Code Playgroud)

python lxml profiling beautifulsoup html-parsing

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

Flash - 提示用户记住相机和麦克风设置

我通过Flash在我的网站上通过麦克风和相机设置请求我的用户,但是没有显示记住复选框,因此每次我的用户登录他再次请求权限时,如何使复选框显示以避免这种情况?

flash permissions camera microphone actionscript-3

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

iOS - UITableView不显示单元格

我在storyboard中设置了以下界面:

在此输入图像描述

控制器是一个从UITableViewController扩展的自定义控制器.当我运行我的应用程序时,这就是我得到的:

在此输入图像描述

我认为它可能与重用标识符有关,所以我将它们更改为每个单元格的唯一内容,并相应地修改了代码,但仍然没有显示任何内容.

uitableview reuseidentifier ios

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

NoMethodError:未定义的方法`call'

运行以下测试套件时:

require 'spec_helper'

describe User do
  before { @user = User.(name: "Example User", email: "user@example.com" }

  subject { @user }

  it { should respond_to(:name) }
  it { should respond_to(:email) }
end  
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Failure/Error: before { @user = User.(name: "Example User", email: "user@example.com") }
NoMethodError:
  undefined method `call' for #<Class:0x007fdfd5dd8008>
  # ./spec/models/user_spec.rb:15:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

创建用户在控制台中工作正常,它响应方法.

ruby rspec ruby-on-rails

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

Obj-C:没有调用委托方法

我是iOS Dev的新手,我正在关注2010年秋季的斯坦福CS193P课程.我正在完成作业3并且我将我的委托设置为我的视图并使用调试器我注意到对我的委托的调用方法不会发生,我不明白会发生什么.我的代码如下:

GraphViewController.h:

@interface GraphViewController : UIViewController <GraphViewDelegate> {
    GraphView *graphView;
    float scale;
}

@property (retain) IBOutlet GraphView *graphView;
@property float scale;

- (IBAction)zoomIn;
- (IBAction)zoomOut;

@end
Run Code Online (Sandbox Code Playgroud)

GraphViewController.m:

@implementation GraphViewController

@synthesize graphView, scale;

- (NSString *)functionForGraph:(GraphView *)requestor {
    NSLog(@"%@", @"culo peluo");
    return @"lol";
}

- (float)scaleForGraph:(GraphView *)requestor {
    return self.scale;
}

- (IBAction)zoomIn {

}

- (IBAction)zoomOut {

}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

    }
    return self;
}

- (void)dealloc
{ …
Run Code Online (Sandbox Code Playgroud)

delegates protocols objective-c ios

3
推荐指数
2
解决办法
1万
查看次数

Ruby - method_missing

我正在尝试实现一个用于将$转换为其他货币的method_missing,就像5.dollars产生5,5.yen将产生0.065 5.euro 6.56等等.我现在可以做.现在我需要实现它,但是以5.dollars.in(:yen)为例.

这就是我现在所拥有的:

class Numeric
  @@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019}
  def method_missing(method_id)
    singular_currency = method_id.to_s.gsub( /s$/, '')
    if @@currencies.has_key?(singular_currency)
      self * @@currencies[singular_currency]
    else
      super
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释我怎么做到这一点?

PS:我宁愿你不给我代码,而是解释,所以我可以自己确定它是如何完成的.

ruby metaprogramming method-missing

3
推荐指数
2
解决办法
1万
查看次数