我有一个UITextFieldDelegate的UIViewController,我希望一旦用户导航到该视图就会显示其文本字段的键盘,而不必实际触摸文本字段.当键盘被解除时能够"解散"整个视图也是很好的.我正在从xib文件加载视图.
我还没有在UITextField的代码中使用ivar.我猜我需要一个.此时我只是依靠代表弹出键盘.
(我知道它不是UITextViewDelegate,就像标签所说的那样,但我是stackoverflow的新手,无法创建正确的UITextFieldDelegate标签.)
当我更新它所绑定的属性时,我在更新时似乎遇到严重问题让我的WPF UI更新.这是我的视图模型类定义:
namespace WpfModel
{
class AppModel : INotifyPropertyChanged
{
private int _count = 7;
public int Count { get { return _count; }
set { _count = value; OnPropertyChanged("Count"); } }
public void Increment()
{
Count++;
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string prop)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs("prop");
handler(this, e);
}
}
};
}
Run Code Online (Sandbox Code Playgroud)
这与我在以下XAML中的简单UI绑定:
<Window x:Class="WpfModel.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WpfModel"
Title="WPF Data Model Demo" Height="128" Width="284" > …Run Code Online (Sandbox Code Playgroud) 我有一个<textarea>用户输入,并且,正如他们被邀请做的那样,用户可以在浏览器中自由添加换行符,并将这些数据直接保存到数据库中.
在显示这个数据传回在网页上,我需要换行转换为<br>标签在考虑到以可靠的方式\n的了\r\n的,并通过客户端系统中使用的任何其他常见的换行符序列.
在没有每次进行正则表达式替换的情况下,在Perl中执行此操作的最佳方法是什么?我希望,自然,还有另一个令人敬畏的CPAN模块推荐...... :)
我一直遇到将CGPoint转换为字符串的问题.我尝试了各种各样的方法,但这似乎是最有希望的,但它仍然无法正常工作.有什么建议?
这是我的代码:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
coord = [touch locationInView:touch.view];
viewcoord.text = [NSString stringWithFormat:@"coordinates %@", coord.x, coord.y];
Run Code Online (Sandbox Code Playgroud)
我得到输出,但它只是说"坐标(null)",我不明白为什么...
谢谢
我有一个带有2个方法的ProductRepository,GetAllProducts和GetProductByType,我想在GetProductByType上测试逻辑.在内部,GetProductByType调用GetAllProducts,然后过滤正确的.
public virtual IEnumerable<Product> GetAllProducts()
{
//returns all products in memory, db etc
}
public virtual IEnumerable<Product> GetProductsByType(string type)
{
return (from p in GetAllProducts() where p.Type == type select p).ToList();
}
Run Code Online (Sandbox Code Playgroud)
因此,在我的测试中,我想模拟对GetAllProducts的调用,因此它返回在我的测试中定义的产品列表,然后调用原始的GetProductsByType,它将使用模拟的GetAllProducts.
我正在尝试类似下面的代码,但原始的GetProductByType没有被执行,它也被模拟了.在TypeMock中,我有一个CallOriginal方法来解决这个问题,但我无法用Moq来解决这个问题.有任何想法吗?
var mock = new Mock<ProductRepository>();
mock.Setup(r => r.GetAllProducts()).Returns(new List<Product>() {p1, p2, p3});
var result = mock.Object.GetProductsByType("Type1");
Assert.AreEqual(2, result.Count());
Run Code Online (Sandbox Code Playgroud) 我有多个阵列,但是,他们没有保留他们的数据用于另一种方法.
这是我如何设置(简化)
.h
NSArray *array;
@property (nonatomic, copy) NSArray *array;
-(void)someMethod:(NSArray*)someArray;
-(void)heresNewMethod;
Run Code Online (Sandbox Code Playgroud)
.m
-(void)someMethod:(NSArray*)someArray
{
array = [someArray copy];
}
-(void)heresNewMethod //gets called by method not shown
{
NSLog(@"%@", array);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Eclipse中设置一个Android库项目依赖的Android应用程序.我已经建立了一个名为AnTest的项目和一个名为AnLib的库项目.我在AnTest的项目属性中提供了对AnLib的引用.现在我试图从AnTest引用一些库代码(静态公共方法).Eclipse抛出"com.anlib.Hello无法解析为类型".
并不是引用是悬空 - 我可以看到资源正确合并.但是从AnTest中,com.anlib包中唯一的类是"R".
拜托,我做错了什么?必须缺少一些非常基本的步骤......
编辑:我已将AnLib添加到AnTest项目属性中的Java构建路径/项目中.现在它编译,但运行抛出NoClassDefFoundError异常...
我想在Windows 7下使用Windows Virtual PC测试我的WPF应用程序.在我的C#代码中,我正在检查WPF层,如果它小于2,我禁用了DirectX调用.为了在Windows XP上进行测试,我想使用Windows Virtual PC,但它似乎只能在软件模式下运行.因此,等级总是<2.
有关如何使DirectX在Virtual PC中工作的任何想法?
快速问题:我需要允许输入只接受字母,从a到z和从A到Z,但找不到任何表达式.我想使用javascript test()方法.
我正在尝试创建一个相当简单的脚本来处理SQL Server代理作业.它执行2个任务:
1)如果存在给定作业,则将其删除2)创建作业
(由于业务要求我无法修改现有作业,脚本必须删除并重新创建它.)
第一次运行脚本正常工作(创建作业).之后的任何时间运行都会产生错误14274"无法添加,更新或删除源自MSX服务器的作业."
我已经对此进行了大量搜索,大多数解决方案都围绕着正在更改的服务器名称.我的服务器名称没有改变,也没有改变.
这就是我所拥有的:
USE [msdb];
SET NOCOUNT ON;
DECLARE @JobName NVARCHAR(128);
DECLARE @ReturnCode INT;
declare @errCode INT;
SET @JobName = 'AJob';
BEGIN TRANSACTION;
DECLARE @jobId uniqueidentifier;
SET @jobId = (SELECT job_id from msdb.dbo.sysjobs where name = @JobName);
IF(@jobId IS NOT NULL) -- delete if it already exists
begin
EXEC @ReturnCode = msdb.dbo.sp_delete_job @job_id=@jobId
IF(@@ERROR <> 0 OR @ReturnCode <> 0)
begin
set @errCode = @@ERROR;
GOTO QuitWithRollback;
end
print 'deleted job';
end
-- create the job …Run Code Online (Sandbox Code Playgroud) wpf ×2
android ×1
c# ×1
cgpoint ×1
cocoa ×1
cocoa-touch ×1
directx ×1
eclipse ×1
html ×1
iphone ×1
javascript ×1
mocking ×1
moq ×1
nsarray ×1
nsstring ×1
perl ×1
regex ×1
sql-server ×1
string ×1
uitextfield ×1
virtual-pc ×1