我有一个使用Spring IoC进行依赖注入的项目,我试图通过一个访问我的大多数bean的中心位置来略微简化我的模型.
我遇到了使用该@PostConstruct机制的问题,或者在实现InitializingBean接口时遇到了问题.虽然可能已经解决了该特定bean中的所有依赖项,但注入Bean中的依赖项可能不是.例如,我有:
public class A {
public void doSomething() {};
}
public class B {
private A objectA;
@Required
public void setObjectA(A objectA) {
this.objectA = objectA;
}
public A getObjectA() {
return objectA;
}
}
public class C implements InitializingBean {
private B objectB;
@Required
public void setObjectB(B objectB) {
this.objectB = objectB;
}
public void afterPropertiesSet() throws Exception {
objectB.getObjectA().doSomething();
}
}
Run Code Online (Sandbox Code Playgroud)
我的context.xml文件定义了这三个bean并注入了相应的属性,但是NullPointerException当得到类C的对象被实例化并且afterPropertiesSet调用该方法时,我得到一个调试向我显示getObjectA()返回的调用null.如果我将对象A直接注入类CI则不会出错.
是否有一种机制可以用来确保所有bean在我的afterPropertiesSet …
我目前正在使用两个图像作为我构建的菜单.前一段时间我正在使用这个代码用于普通的显示系统,它工作正常,视网膜显示器我在CGImageRef上有一些问题,在背景显示的凹陷上创建正确的蒙版图像.我尝试使用图像扩展名导入视网膜图像.图像使用以下方式提供:
[UIImage imageNamed:@"filename.png"]
Run Code Online (Sandbox Code Playgroud)
我提供了带有filename.png和filename@2x.png名称的标准和视网膜图像.
选择所选区域的遮罩时会出现问题.代码适用于较低分辨率的资源和高分辨率的主资源,但是当我使用时
CGImageCreateWithImageInRect
Run Code Online (Sandbox Code Playgroud)
并指定我要在其中创建图像的矩形,图像的比例增加意味着主按钮的分辨率很好,但返回并叠加在按钮按下的图像不是正确的分辨率,但奇怪地缩放到两次像素密度,看起来很糟糕.
我试过了两个
UIImage *img2 = [UIImage imageWithCGImage:cgImg scale:[img scale] orientation:[img imageOrientation]];
UIImage *scaledImage = [UIImage imageWithCGImage:[img2 CGImage] scale:4.0 orientation:UIImageOrientationUp];
Run Code Online (Sandbox Code Playgroud)
当我拍摄图像和drawInRect时,我似乎无处可去:(选定的矩形)
我现在已经把头发撕掉了大约2个小时,似乎找不到合适的解决方案,有没有人有任何想法?
我正在尝试为我的UIViews添加功能(根据状态配置CALayers),设置一个NSProxy子类代替我选择的任何UIView.这是我尝试过的:
在我的NSProxy子类中,我有以下代码:
#pragma mark Initialization / Dealloc
- (id)initWithView:(UIView *)view
{
delegate = view;
[delegate retain];
return self;
}
- (void)dealloc
{
[delegate release];
[super dealloc];
}
#pragma mark Proxy Methods
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
[anInvocation setTarget:delegate];
[anInvocation invoke];
return;
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
return [delegate methodSignatureForSelector:aSelector];
}
- (BOOL)respondsToSelector:(SEL)aSelector
{
BOOL rv = NO;
if ([delegate respondsToSelector:aSelector]) { rv = YES; }
return rv;
}
Run Code Online (Sandbox Code Playgroud)
并且,以这种方式使用我的NSProxy子类:
UILabel *label = [[HFMultiStateProxy alloc] initWithView:[[[UILabel alloc] initWithFrame:cellFrame] autorelease]];
label.text = text; …Run Code Online (Sandbox Code Playgroud) 我是bash脚本的新手.我似乎无法获得我的计数变量的正确值,以便while在我的bash脚本的循环结束时显示.
背景:我有一个相当简单的任务:我想将包含文件路径列表的文本文件传递给bash脚本,让它检查这些文件是否存在,并计算现有/丢失文件的数量.除了计数部分外,我得到了大部分脚本.
N=0
correct=0
incorrect=0
cat $1 | while read filename ; do
N=$((N+1))
echo "$N"
if ! [ -f $filename ]; then
incorrect=$((incorrect+1))
else
correct=$((correct+1))
fi
done
echo "# of Correct Paths: $correct"
echo "# of Incorrect Paths: $incorrect"
echo "Total # of Files: $N"
Run Code Online (Sandbox Code Playgroud)
如果我有一个包含5个文件的列表,其中4个存在,我希望得到以下输出(注意循环中的echo命令while):
1
2
3
4
5
# of Correct Paths: 4
# of Incorrect Paths: 1
Total # of Files: 5
Run Code Online (Sandbox Code Playgroud)
相反,我得到:
1
2
3
4
5
# …Run Code Online (Sandbox Code Playgroud) 我有两个独立的ItemsControls并排出现.在ItemsControl小号绑定到相同的ItemsSource,但他们不同的方式显示数据.
左侧显示的每个项目很可能小于右侧的相同项目.这会导致问题,因为行不会排成一行,因此我需要左侧的项目绑定到右侧的项目.
ItemsControl ItemsControl
|Item 1 |Item 1
|Item 2 |Item 2
|Item 3 |
|Item 4 |Item 3
Run Code Online (Sandbox Code Playgroud)
如您所见,右侧的第2项更大,因此它会抛弃对齐.因此,如果我可以将左侧的项目2绑定到右侧的项目2,ActualHeight则问题将得到解决.我怎样才能在XAML中做到这一点?
编辑:为了使事情变得更复杂,ItemsControl右边需要从右向左滚动,但两者都ItemsControls需要一起向上和向下滚动.基本上,左边的一个为右边的项目提供了各种标题.
嗨如果两个参数都是可选的,我如何映射网址../Companies/Results/value/id?
公司是控制器,结果是动作,值和id是可选参数.在我的表单上是一个值的文本框和一个id的选择列表.用户可以选择两个或每个中的一个来搜索.尝试过这样的事情,但是当其中一个可选参数(例如值)丢失时无法处理,例如../Companies/Results//id
routes.MapRoute(
"Company+Profession", // Route name
"{action}/{value}/{profId}", // URL with parameters
new { controller = "Companies", action = "Index", value = UrlParameter.Optional, profId = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud) __dict__在Python中定义一个"普通"类?__dict__s 的非动态类型的例子?PyTypeObject通过type_new?有一个tp_dict成员PyTypeObject,但我找不到有关它如何使用的信息.此外,还似乎有什么东西在事情typeobject.c的type_new,但我不能清楚地破译它.
以下是我发现的一些相关信息:
我有一个布局,有三个字段用于输入三个地图坐标.到现在为止还挺好.我在布局中使用android:inputType ="numberDecimal".当进入该字段时,用户获得数字小键盘.还好.
但是,当需要输入负坐标时,没有明显的方法可以做到这一点.
23.2342工作正常.232.3421工作正常.无法输入-11.23423 - 无法输入前导负号,甚至无法将坐标包装在()中.
我确信我可以将其更改为直接文本inputType,然后使用正则表达式来验证输入的内容实际上是一个数字坐标,处理错误消息回发给用户等等.但是我会而不是去那条路.
我用谷歌搜索和Stackoverflowed这个问题几个小时没有运气.有什么建议?
我不明白以下代码如何编译/不编译:
struct Temp
{
int i;
};
int main(int argc, char * argv[])
{
//Temp &ref1 = (Temp){42}; // Error, as expected
Temp &ref2 = *(Temp*)&(Temp){42}; // A-OK
std::cerr << ref2.i << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用g ++ 4.4.4.
在肯定文本字段中,我按下换行按钮并放置空格.但是,在我单击完成后,该字段实际上具有正确的新行(第二个屏幕捕获).
它不是设备的问题,因为它适用于gmail应用程序中提交的撰写邮件.这是我希望如何工作的方式.


<TextView
android:inputType="textMultiLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="@string/edit_affimation"
/>
<EditText
android:id="@+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false"
>
</EditText>
Run Code Online (Sandbox Code Playgroud) android ×2
iphone ×2
actualheight ×1
asp.net ×1
asp.net-mvc ×1
bash ×1
binding ×1
c ×1
c++ ×1
calayer ×1
cgimage ×1
g++ ×1
ios4 ×1
itemscontrol ×1
java ×1
layout ×1
nsproxy ×1
parameters ×1
python ×1
python-3.x ×1
python-c-api ×1
reference ×1
routing ×1
rvalue ×1
scripting ×1
shell ×1
spring ×1
types ×1
uilabel ×1
uiview ×1
variables ×1
wpf ×1
xaml ×1