English 中文(简体)
简明星座
原标题:Simple Metronome iPhone App

我正试图建立一个简单的元数据,我很想知道,那里是否有任何样本代码或开放源项目来学习。 我认为,这只是一个pple。 我认为,不应该是困难的,但我很想知道如何装上音响,如何设置时间并相应地播音。 任何帮助都受到高度赞赏。

最佳回答

果 Apple星应用仍可在SOS 4.2图书馆查阅。

In Xcode simply go to Window -> Organizer.
Then go to the Documentation pane and search for Metronome.
The Metronome project will appear under the Sample Code section.

你们可以确保有SOS 4.2图书馆,途径是提供参考书——“设计书”;下载——“设计书”;文件和确保SOS 4.2图书馆列入你名单。

So...as of Summer 2015, Apple s redesign of their website seems to have broken these links. I have found the docket link in .xar format http://devimages.apple.com/docsets/20101122/com.apple.adc.documentation.AppleiOS4_2.iOSLibrary.Xcode4.xar which you can download and then extract with the xar -xf <docsetfilename> command line tool or else something like the unarchiver app.

问题回答

我对国家安全局进行了审判,但如果你在寻找普罗梅诺米的话,这不是一个好的解决方案。 你们需要一个核心引擎,把时间推到所需要的位置。 国家安全局请你在你需要精准的时间空间上休息。

看看现在,5世纪之光,请你使用音乐会,这是音乐应用的良好解决办法。 而且 它拥有控制时间的核心动力。

This is a metronome project that I ve made previously, It s fairly simple but It should help, If you use it just reference me, Jordan Brown 15y Mango Apps. It took a while to do but never made an app out of it.

        //.h
NSTimer *timer;
int count;
float bpm;
float speed;
UILabel *numberLabel;
IBOutlet UISwitch *vibrate;
IBOutlet UISegmentedControl *timing;
 }
 - (IBAction)up;
 - (IBAction)down;
 - (IBAction)stop:(id)sender;
 @property (nonatomic, retain)IBOutlet UILabel *numberLabel;
 @property (nonatomic, retain)IBOutlet UILabel *bpmLabel;

 @property (nonatomic, retain)IBOutlet UISegmentedControl *timing;



 //.m
  #define SECONDS 60
  #import <AudioToolbox/AudioToolbox.h>

 @implementation metronome
  @synthesize numberLabel; // labels
  @synthesize bpmLabel;
  @synthesize timing; 

-(IBAction)stop:(id)sender{
[timer invalidate];
[self performSelector:@selector(playTockSound)];
numberLabel.text = [NSString stringWithFormat:@"%i",count];
bpm = bpm;
if (bpm > 300) {
    bpm = 300;
}
int new = bpm;

bpmLabel.text = [NSString stringWithFormat:@"%i",new];
speed = INFINITY;

NSLog(@"%f",speed);
timer = [NSTimer scheduledTimerWithTimeInterval:speed target:self selector:@selector(updateNumber) userInfo:nil repeats:YES];

}
 -(IBAction)up{
 [timer invalidate];
count = 1;
[self performSelector:@selector(playTockSound)];
numberLabel.text = [NSString stringWithFormat:@"%i",count];
bpm = bpm+10;
if (bpm > 300) {
    bpm = 300;
}
int new = bpm;

bpmLabel.text = [NSString stringWithFormat:@"%i",new];
speed = SECONDS/bpm;

NSLog(@"%f",speed);
timer = [NSTimer scheduledTimerWithTimeInterval:speed target:self selector:@selector(updateNumber) userInfo:nil repeats:YES];
 }
-(IBAction)down{
 [timer invalidate];
count = 1;
[self performSelector:@selector(playTockSound)];
numberLabel.text = [NSString stringWithFormat:@"%i",count];
bpm = bpm-10;
if (bpm < 10) {
    bpm = 10;
}
int new = bpm;

bpmLabel.text = [NSString stringWithFormat:@"%i",new];
speed = SECONDS/bpm;
NSLog(@"%f",speed);
timer = [NSTimer scheduledTimerWithTimeInterval:SECONDS/bpm target:self               selector:@selector(updateNumber) userInfo:nil repeats:YES];

  }
  -(void)updateNumber{
count += 1;
//if 4/4 timing is selected then the count wont go past 4
if (timing.selectedSegmentIndex == 2) {
if (count >= 5) {
    count = 1;
}
}

//if 3/4 timing is selected then the count wont go past 3
if (timing.selectedSegmentIndex == 1) {
    if (count >= 4) {
        count = 1;
    }
}

//if 2/4 timing is selected then the count wont go past 2
if (timing.selectedSegmentIndex == 0) {
    if (count >= 3) {
        count = 1;
    }
}    
  //In each timing case it plays the sound on one and depending 
  //on the limitiations on the cont value the amount of each tick 
      if (count == 1) {
    [self performSelector:@selector(playTockSound)];
}else {
    [self performSelector:@selector(playTickSound)];
}

numberLabel.text = [NSString stringWithFormat:@"%i",count];
  }
  -(void)playTickSound
  {
NSString *path = [[NSBundle mainBundle] pathForResource:@"tick" 
                                                 ofType:@"caf"];
SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                 , &soundID);
  AudioServicesPlaySystemSound (soundID);




  }
  -(void)playTockSound
  {
NSString *path = [[NSBundle mainBundle] pathForResource:@"tock" 
                                                 ofType:@"caf"];

SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
                                 , &soundID);
     AudioServicesPlaySystemSound (soundID);



  - (void)didReceiveMemoryWarning
  {
// Releases the view if it doesn t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren t in use.
  }


  - (void)viewDidLoad
  {
bpm = 60.00;
speed = SECONDS/bpm;
timer = [NSTimer scheduledTimerWithTimeInterval:speed target:self selector:@selector(updateNumber) userInfo:nil repeats:YES];
int new = bpm;

bpmLabel.text = [NSString stringWithFormat:@"%i",new];
[super viewDidLoad];

  }

就在谷歌的目的而言,我就此得出了结论。 我尝试了“ Apple果”办法(利用背景镜)和“NStimer”办法,而到现在,胜者就是使用read。 在主线(UI)穿透时,只剩下一段路要让一名国家工时准确开火。 我相信,你会有一个时间,但 Apple果的榜样确实非常好。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签