我无法播放mp3音频文件.
URL_PATH = @"http://...../.…./A1.mp3";
Run Code Online (Sandbox Code Playgroud)
NSError*错误;
player = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL URLWithString:URL_PATH] error:&error];
if (error)
{
NSLog(@"error:%@",error.localizedDescription);
}
if (player ==nil)
{
NSLog(@"nil");
}
else
{
NSLog(@"playing");
[player play];
}
Run Code Online (Sandbox Code Playgroud)
错误代码 :
error:The operation couldn’t be completed. (OSStatus error -43.)
nil
Run Code Online (Sandbox Code Playgroud)
我能怎么做?请告诉我提示.预先感谢!
我创建了一个Constants.h文件,其中包含以下列表:
#define kw00 @"foo"
#define kw01 @"bar"
...
Run Code Online (Sandbox Code Playgroud)
我也在Constants.h.h中使用#import .使用newQuote方法,我想随机选择的一个kw strings,但我有困难,探索如何call a reference以一个constant是字符串中定义kwString.
-(IBAction)newQuote
{
int rNumber = arc4random() % kwTotal;
(rNumber <9)
{
NSString *kwString = [@"kw0" stringByAppendingString:[NSString stringWithFormat:@"%d", rNumber]];
}
}
Run Code Online (Sandbox Code Playgroud)
我们非常感谢您的想法和建议.
我有两个viewControllers访问NSNumber的AppDelegate.其中一个人可以看到它,而另一个则不能.我对这完全感到困惑.
有问题的那个有这个代码.
AppDelegate *dataStore = (AppDelegate *)[[UIApplication sharedApplication] delegate];
dataStore.downHUD = [NSNumber numberWithFloat:(float)progress];
Run Code Online (Sandbox Code Playgroud)
另一个有这个.
AppDelegate *dataStore = (AppDelegate *)[[UIApplication sharedApplication] delegate];
dataStore.downHUD = [NSNumber numberWithFloat:(float)0];
Run Code Online (Sandbox Code Playgroud)
两者都在.m文件中导入AppDelegate,但我最终得到了
在'AppDelegate*'类型的对象上找不到属性'downHUD'
与第一个.谁能帮我看看有什么不对?
我错误地复制并粘贴了很多代码AppDelegate,这已得到纠正.是否有某种链接可能被破坏?
- (void)viewDidLoad
{
self.imageview.image = [UIImage imageNamed:@"Image.png"];
[self.view addSubview: self.imageview];
[super viewDidLoad];
}
Run Code Online (Sandbox Code Playgroud)
此代码用于移动图像
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
self.imageview.center = touchLocation;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// get touch event
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.PlayVideo];
if ([touch view] == self.view)
{
self.imageview.center = touchLocation;
}
}
Run Code Online (Sandbox Code Playgroud)
此代码用于旋转图像(T将旋转手势放到图像上并拖到.h文件中)
- (IBAction)regRotation:(UIGestureRecognizer *)sender
{
NSLog(@"rotation");
CGFloat netRotation =0.0;
CGFloat rotation =[(UIRotationGestureRecognizer *)sender rotation];
CGAffineTransform …Run Code Online (Sandbox Code Playgroud) 海IAM新的objective c和iOS发展
设置UIImageview图像.尝试以下代码
arrowImgVw is UIImageView Class object
UIImage *image=[[UIImage alloc]init];
image=[UIImage imageNamed:@"return_journey_denoter.png"];
arrowImgVw.image = image;
Run Code Online (Sandbox Code Playgroud)