我有一个AVAudioRecorder,它被初始化为:
_recorder = [AVAudioRecorder alloc];
NSMutableDictionary *recordSettings = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
[recordSettings setObject:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey: AVFormatIDKey];
[recordSettings setObject:[NSNumber numberWithInt:AVAudioQualityLow] forKey: AVEncoderAudioQualityKey];
NSURL *url = [NSURL fileURLWithPath:[self getActualSoundPath]];
[_recorder initWithURL:url settings:recordSettings error:nil];
[_recorder setDelegate:self];
Run Code Online (Sandbox Code Playgroud)
这段代码在我的模拟器和我的iPhone 3GS上完美运行,但在旧的iPhone 3G上却没有...
有什么问题?
谢谢马库斯
我使用此代码在屏幕上获取鼠标位置并且它正在工作。我也得到光标的宽度和高度。我需要的是在调用函数 GetIconInfo 时的光标图标。在 ii iI 中有 ii.hbmColor 和 ii.hbmMask。hbmColor 的值为 0x0,hbmMask 的值为 0x2f0517f1。我可以从那两个指针中提取鼠标光标吗?如何提取?
CURSORINFO cursorInfo = { 0 };
cursorInfo.cbSize = sizeof(cursorInfo);
HDC memoryDC = (HDC)malloc(100);
memset(memoryDC, 0x00, 100);
if (::GetCursorInfo(&cursorInfo)) {
ICONINFO ii = {0};
GetIconInfo(cursorInfo.hCursor, &ii);
BITMAP bm;
GetObject(ii.hbmMask,sizeof(BITMAP),&bm);
DeleteObject(ii.hbmColor);
DeleteObject(ii.hbmMask);
::DrawIcon(memoryDC, cursorInfo.ptScreenPos.x - ii.xHotspot, cursorInfo.ptScreenPos.y - ii.yHotspot, cursorInfo.hCursor);
for(int i = 0; i < bm.bmWidth; i++){
for(int j = 0; j < bm.bmHeight; j++){
COLORREF c = GetPixel(memoryDC, i, j);
printf("%x", c);
}
}
}
Run Code Online (Sandbox Code Playgroud) 我需要一个采用Action(或Func)的方法,但Action有一个混合数量的参数.实现这些重载的最直接,最紧凑的方法是什么:
public void Execute<T>(Action<T> action, T param) {
// TODO: Implement something like:
// Execute(action, param, null);
}
public void Execute<T1,T2>(Action<T1,T2> action, T1 param1, T2 param2) {
// TODO: Implement something like:
// Execute(action, param1, param2, null);
}
public void Execute<T1,T2,T3>(Action<T1,T2,T3> action, T1 param1, T2 param2, T3 param3) {
DoStuff();
action(param1, param2, param3)
DoMoreStuff();
}
// OR any other type of higher order function-solution
public void Execute(Action action, params object[] parameters) { ... } // ???
Run Code Online (Sandbox Code Playgroud)
除了执行操作及其参数之外,方法的内容完全相同.
如果可能,请不要使用任何特定于C#4.0的功能来解决此问题.
刚从ASP.NET开始,发现很难使用GridView.我有一组Session变量,我想放入GridView控件,但我缺乏知识.文件:
<%@ Page Title="Warehouse" Language="C#" AutoEventWireup="true"
MasterPageFile="~/Site.master"
CodeFile="Warehouse.aspx.cs" Inherits="Warehouse" %>
<asp:Content ID="HeaderContent" runat="server"
ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Warehouse
</h2>
<asp:Panel ID="WarehousePanel" runat="server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</asp:Panel>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
在后面的代码中我想将会话变量添加到GridView1,仅用于显示目的.稍后它将连接到数据库,但是为了练习,我想知道如何将会话变量添加到GridView1.文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Warehouse : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["milk"] == null)
Session["milk"] = "0";
if (Session["apple"] == null)
Session["apple"] = "0";
if (Session["orange"] == null)
Session["orange"] = "0";
// …Run Code Online (Sandbox Code Playgroud) 我想在NSMenu项目的其中一个条目中添加一个下拉菜单.(例如,如果单击Finder栏上的电池指示器,它有一个Show-> Icon,Time,Percentage选项).现在我使用以下代码添加一个MenuItem:
menuItem = [menu addItemWithTitle:@"Start"
action:@selector(start:) keyEquivalent:@""];
[menuItem setTarget:self];
Run Code Online (Sandbox Code Playgroud)
如何使用此下拉列表添加子菜单项?谢谢.
使用以下代码时,字段的id和标签的for属性中的id不相同.
<%: Html.LabelFor(x => x.Localizations["en"]) %> => Localizations[en]
<%: Html.TextBoxFor(x=> x.Localizations["en"]) %> => Localizations_en_
<%: Html.LabelFor(x => x.Localizations["en"].Property) %>
=> Localizations[en]_Property
<%: Html.TextBoxFor(x=> x.Localizations["en"].Property) %>
=> Localizations_en__Property
Run Code Online (Sandbox Code Playgroud)
我在反射器中跟踪代码,发现生成值的方式不同.不使用相同的帮助方法.
LabelFor用途HtmlHelper.GenerateIdFromName和TextBoxFor用途TagBuilder#GenerateId.
有没有人知道这个的原因,或解决方法(除了编写你自己的整套输入/ textarea /选择助手)?或者这是一个错误?
更新:
因为我总是使用标签文本的第二个参数为标签使用html帮助器,我修改它以使用与表单字段助手相同的id生成代码.
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, string labelText)
{
// The main part of this code is taken from the internal code for Html.LabelFor<TModel, TValue>(...).
var metaData = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var fieldName = ExpressionHelper.GetExpressionText(expression);
TagBuilder builder = new …Run Code Online (Sandbox Code Playgroud) 我希望在键盘上的textarea中获得插入符号的X/Y坐标.我已经大力搜索但没有任何运气,似乎你可以得到位置,但不是屏幕上的X/Y坐标.
我有一个发布到外部API的表单.有一个名为customer_token的参数,它作为输入字段传递.它用于API的身份验证,并为每个客户分配一个令牌.输入字段在Firefox的Firebug中可见(即使它是隐藏字段).
我怎么隐藏它?
选项 使用我最初想到的javascript
我认为在提交表单之前使用javascript在运行时创建输入字段并立即删除该字段将起作用,但该字段将暂时出现.因此,即使一个人无法手动获取它,我担心爬虫或蜘蛛(我不知道确切的术语 - 但是一些自动化脚本)可能会获得客户令牌.有更好的解决方案吗?表单提交后,仍会显示相同的表单.
使用Ikke建议的一次性令牌概念
我不确定它会如何起作用?API需要正确的客户令牌值来处理任何请求.因此,即使生成一次性令牌并返回,也必须发送带有客户令牌的请求.这样,任何人都可以看到我的客户令牌值,他们也可以发送请求获取一次性令牌并使用它.那怎么解决这个问题呢?
已解决 检查如何将表单发布到我的服务器然后发布到API,而不是直接发布(出于安全原因)? 谢谢,Sandeepan
我目前正在用Java编写一些软件,我可能有一天会决定在线销售.我正在使用Java SE库.如果我计划出售这个,我是否必须向甲骨文支付任何许可费用,因为最近甲骨文起诉谷歌的消息我担心这个平台的未来.
谢谢,
我有一个用户评论很长的专栏.我使用以下代码加载它...
<my:DataGridTextColumn Header="Message"
Binding="{Binding UserMessage, Mode=OneWay}"
CanUserSort="True">
<my:DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}"
BasedOn="{StaticResource {x:Type TextBlock}}">
<Setter Property="TextWrapping"
Value="NoWrap" />
<Setter Property="TextTrimming"
Value="CharacterEllipsis"/>
<Setter Property="ToolTip"
Value="{Binding Path=UserMessage, Mode=OneWay}"/>
</Style>
</my:DataGridTextColumn.ElementStyle>
</my:DataGridTextColumn>
Run Code Online (Sandbox Code Playgroud)
但省略号不起作用.该列继续显示长文本数据.此外,当我明确地将文本块的宽度设置为某个值时,省略号工作正常,但是当我调整列的大小时,它不再显示其中的任何文本.
不是有一个明星的方式来做到这一点?
Thx Vinit Sankhe.
c# ×2
.net ×1
3g ×1
action ×1
asp.net ×1
asp.net-mvc ×1
c++ ×1
caret ×1
cocoa ×1
cursor ×1
datagrid ×1
ellipsis ×1
forms ×1
func ×1
gridview ×1
html ×1
html-helper ×1
iphone ×1
iphone-3gs ×1
java ×1
javascript ×1
jquery ×1
mouse ×1
nsmenuitem ×1
overloading ×1
parameters ×1
textarea ×1
windows ×1
wpf ×1