我写了一个应该在iPad和iPhone上运行的应用程序.我正在使用AVAudioPlayer播放声音.现在我遇到了音量水平的一些问题.
在iPad上运行时,一切都很好,播放声音的音量水平也很好,在iPad模拟器中运行也是如此.
当应用程序在iPhone上运行时出现问题:虽然iPhone模拟器中的音量水平很好,但设备上的音量非常低.
这是我在两台设备上使用的代码:
if (audioPlayerAtmo==nil)
{
NSString *filename = [NSString stringWithFormat:@"Atmo_%i", currentPage];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:@"mp3"]];
AVAudioPlayer *tempPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
tempPlayer.delegate = self;
//NSLog(@"tempPlayer.volume: %f", [tempPlayer volume]);
[tempPlayer setVolume:1.0f];
//NSLog(@"tempPlayer.volume: %f", [tempPlayer volume]);
self.audioPlayerAtmo = tempPlayer;
[tempPlayer release];
[audioPlayerAtmo play];
btAtmo.selected = YES;
}
else // player exists
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
有人知道为什么iPhone的级别如此之低,而模拟器和iPad上的一切都很好吗?
在此先感谢您的帮助.
技术数据:XCode 3.2.4 iPhone 4(Vers.4.1)
我无法解决这个问题.
我有一个商业模式和一个地址模型.为了使事情变得更复杂,我也有一个位置模型.企业可以有多个位置,但只有一个邮寄地址.
这是一个简单的对象图表.
业务
-Name
-MailingAddress
位置
-Business
-Name
-Address
我想重用业务和位置的地址模型.我需要做些什么呢.如果它有帮助,我正在使用MySQL.
首先我如何构建模型?我是否需要has_many:location,:business(适用于位置/业务)?然后,如何将用于创建地址的表单嵌套到新的业务/位置表单中.
谢谢!
谢谢你停下来....
我已按照以下链接了解iPhone中的In App购买....
http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-in-app-purchases/
当我在xcode上运行代码时没有发现错误.
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
NSLog(@"Failed to connect with error: %@", [error localizedDescription]);
}
Run Code Online (Sandbox Code Playgroud)
但在控制台我得到以下错误
"SKProductsRequest:0x5c0ec80>:在模拟器中立即失败"
任何帮助都感激不尽...
我一直在玩CouchDB和CouchApp一段时间了.我正计划将它用于我正在开发的新网站项目.
从可扩展性的角度来看,我喜欢CouchApp的想法.
缺点是没有服务器端代码,有些东西(如oAuth身份验证)在客户端很难做到.在某些时候,我确定我需要一些描述的服务器端代码 - 我想你可以看看Node.js,但不想在这一点上.
使用CouchDB纯粹作为后端解决方案,而您的页面是从另一台服务器提供的,这也很合适,但缺点是跨域问题阻止您轻松使用内置的CouchDB API.
那么有没有人能解决这两个缺点之一呢?
你能以某种方式从CouchApp服务于服务器端代码(甚至PHP会赢)或者你能以某种方式使用一个单独的网站来服务你的网页但是克服了跨域问题吗?
我真的试图让解决方案尽可能干净(并且可扩展),而CouchDB的一个好处就是超级简单,超快速的API,所以我真的不想在它周围使用包装器 - 除非它没有阻碍了性能/可扩展性.
欢迎您的意见.
我有以下型号
class Order < AR::Base
has_many :products
accepts_nested_attributes_for :products
end
class Product < AR::Base
belongs_to :order
has_and_belongs_to_many :stores
accepts_nested_attributes_for :stores
end
class Store < AR::Base
has_and_belongs_to_many :products
end
Run Code Online (Sandbox Code Playgroud)
现在我有一个订单视图,我想更新产品的商店.问题是我只想将产品连接到我的数据库中的现有商店,而不是创建新商店.
我在订单视图中的表单看起来像这样(使用Formtastic):
= semantic_form_for @order do |f|
= f.inputs :for => :live_products do |live_products_form|
= live_products_form.inputs :for => :stores do |stores_form|
= stores_form.input :name, :as => :select, :collection => Store.all.map(&:name)
Run Code Online (Sandbox Code Playgroud)
虽然它嵌套它工作正常.问题是,当我选择商店并尝试更新订单(以及产品和商店)时,Rails会尝试创建一个具有该名称的新商店.我希望它只使用现有商店并将产品连接到该商店.
任何帮助赞赏!
编辑1:
最后,我以一种非常粗暴的方式解决了这个问题:
# ProductsController
def update
[...]
# Filter out stores
stores_attributes = params[:product].delete(:stores_attributes)
@product.attributes = params[:product]
if stores_attributes.present?
# …
Run Code Online (Sandbox Code Playgroud) 我在html页面中使用文件控件我想在用户点击重置按钮时从控件中删除文件位置.
$("#control").val("");
Run Code Online (Sandbox Code Playgroud)
如果我运行此代码他不能在Chrome中工作但在Firefox中工作
我该怎么做才能取消选择未在文件上传控件中选择的文件.
如何重置控件而不重置整个表单.有任何事情可以做到这一点.
我有面板和各种控件.我想将此面板的图像保存到文件中,我该怎么做?
我需要做一些截图,但我只需要在我的应用程序中使用某个面板的图像,我想在我的应用程序中点击一下按钮.
最好的问候,Primoz
编辑:我也使用此代码在此面板上绘制
Graphics g = chartTemperature.CreateGraphics();
g.DrawLine(p, prevPoint, e.Location);
prevPoint = e.Location;
Run Code Online (Sandbox Code Playgroud)
但后来我没有把它变成图像.为什么,以及如何解决这个问题?
编辑2:
namespace Grafi
{
public partial class Form1 : Form
{
bool isDrawing = false;
Point prevPoint;
public Form1()
{
InitializeComponent();
}
private void chartTemperature_MouseDown(object sender, MouseEventArgs e)
{
isDrawing = true;
prevPoint = e.Location;
}
private void chartTemperature_MouseMove(object sender, MouseEventArgs e)
{
Pen p = new Pen(Color.Red, 2);
if (isDrawing)
{
Graphics g = chartTemperature.CreateGraphics();
g.DrawLine(p, prevPoint, e.Location);
prevPoint = e.Location;
numOfMouseEvents = 0; …
Run Code Online (Sandbox Code Playgroud) 这是我长期以来一直想知道的事情.请看以下示例:
struct matrix
{
float data[16];
};
Run Code Online (Sandbox Code Playgroud)
我知道默认构造函数和析构函数在这个特定示例中做了什么(没有),但是复制构造函数和复制赋值运算符呢?
struct matrix
{
float data[16];
// automatically generated copy constructor
matrix(const matrix& that) : // What happens here?
{
// (or here?)
}
// automatically generated copy assignment operator
matrix& operator=(const matrix& that)
{
// What happens here?
return *this;
}
};
Run Code Online (Sandbox Code Playgroud)
它涉及std::copy
或std::uninitialized_copy
或memcpy
或memmove
或什么?
Ruby on Rails:我想在localhost上调用一个控制器,但服务器说!!! 缺少mysql gem.将它添加到您的Gemfile:gem'mysql','2.8.1'
问题 ?当我点击'gem list'命令然后我得到一个列表女巫包含mysql 2.8.1.所以宝石是安装的!为什么不能通过webrick看到它?
谢谢.