我是iOS和Sprite Kit编程的新手,并想知道如何组合:
-[SKAction runAction:withKey:]
Run Code Online (Sandbox Code Playgroud)
和
-[SKAction runAction:completion:]
Run Code Online (Sandbox Code Playgroud)
一方面,我想阻止一个节点再次运行相同的动作(或动作序列),另一方面,我想对一个动作的终止作出反应,但是没有方法,据我所知,无法同时使用两者.
谢谢
我的应用程序想要获取iphone的专辑列表和某些专辑中的所有照片.
在应用程序中,我列举了iphone的一张专辑中的照片.由于某些专辑可能有很多照片,考虑到性能,我使用GCD:dispatch_async.但是当KVO调用的tableview单元格更新时,它总是崩溃.我不知道我是否以错误的方式使用KVO或GCD.
现在,我使用performSelectorInBackground:替换dispatch_async.现在应用程序没有崩溃,但应用程序的性能很差:只有当你触摸它时才会显示单元格的标题,或者当有很多照片时滚动桌面视图.换句话说,必须阻止主线程.
附件是代码,核心代码在AlbumListViewController.m中.
任何人都可以帮我检查一下吗?
我只想知道:1如果使用dispatch_async 2,应用程序崩溃的原因2如果有很多照片,我怎样才能提高性能.
谢谢.
以下是我的代码:
//
// RootViewController.h
// AlbumDemo
#import
@interface RootViewController : UITableViewController {
NSMutableArray *_listArray;
}
@property (nonatomic, retain) NSMutableArray *listArray;
@end
// RootViewController.m
#import "RootViewController.h"
#import
#import "AlbumListViewController.h"
NSString *thumnail = @"thumnail";
NSString *albumName = @"albumName";
NSString *albumNum = @"albumNum";
NSString *albumGroup = @"albumGroup";
@implementation RootViewController
@synthesize listArray = _listArray;
#pragma -
#pragma Function
- (void)setUp
{
_listArray = [[NSMutableArray alloc] initWithCapacity:1];
self.title = @"Albums";
}
- (void)fetchAlbumList
{
ALAssetsLibrary *assetLib = … 这是一个新手问题.
我有一个非常简单的应用程序,当点击主视图上的按钮时,它应该只播放音频文件.
我正在使用XCode版本4.6.
我在我的项目中添加了一个音频文件'audioclip.wav'.我添加了AVFoundation.framework.
我的项目只有ViewController.h和ViewController.m.
我双击并从故事板中的按钮拖动到.h文件,使用助理编辑器创建我的IBAction连接.
我的ViewController.h:
#import <UIKit/UIKit.h>
#import<AVFoundation/AVAudioPlayer.h>
@interface ViewController : UIViewController <AVAudioPlayerDelegate> {
}
- (IBAction)playAudio:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
我的ViewController.m:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)playAudio:(id)sender {
AVAudioPlayer *audioPlayer;
NSString *audioPath = [[NSBundle …Run Code Online (Sandbox Code Playgroud)