我遇到了这个错误,发现很少有关于如何在线修复它的文档.我通过尝试运行该命令得到了错误git add .
,并收到了此响应:
致命:无法统计'myPathToAFile':没有这样的文件或目录
我不知道这是否可行,但我想做的是在视图中多次添加一个子视图.我尝试过这样的事情:
[self.view addSubview: newView];
newView.center = CGPointMake(160, 100);
[self.view addSubview: newView];
newView.center = CGPointMake(160, 200);
[self.view addSubview: newView];
Run Code Online (Sandbox Code Playgroud)
所有这一切都是四处newView
走动,而不是添加新的.有任何想法吗?
我也试过这个:
[self.view addSubview:newView];
UIView *anotherView = newView;
anotherView.center = CGPointMake(160, 100)
[self.view addSubview:anotherView];
Run Code Online (Sandbox Code Playgroud)
编辑
这是我随着时间学习的解决方案
解决问题的另一种方法是创建一个包含视图的单独nib,并多次添加nib的实例.一个好的模板工作过实施该解决方案是做同样的方式自定义UITableViewCell
在使用cellForRowAtIndexPath
方法.
我有一个角度2应用程序,有一个名为User的类.此用户具有名为deleted_at的属性,该属性为null或包含日期时间,显然,如果deleted_at属性不为null,则删除用户.这是我的user.ts文件的外观:
User.ts
export class User {
id: number;
email: string;
created_at: string;
first_name: string;
last_name: string;
deleted_at: any;
name() {
if (this.deleted_at === null) {
return this.first_name;
} else {
return 'DELETED';
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我希望我可以用一个简单的行在模板中调用name:
{{ user.name }}
Run Code Online (Sandbox Code Playgroud)
然而,这不会返回任何内容,如何调用角度2模板中的某些函数?或者这不允许吗?
编辑:清除一些东西,这是我在我的组件user-list.component.ts中使用的类用户,在此组件中处理多个用户.
我有一个按钮,背景在xml中定义.我想根据它所处的当前状态对按钮着色 - 即 - 按下,聚焦,正常.
这是我下面的xml文件.此外,我colored_tint_dark
,并且colored_tint
都是半透明的颜色,我试图绘制在我从资源文件夹调用的可绘制图像.这是问题所在.当UI首次加载时,图像上具有适当的色调,但是在按下之后,按下的状态不显示任何色调,则正常状态将不显示任何色调.
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<item android:state_pressed="true" android:drawable="@drawable/rounded_grayscale_pinstripe_button">
<shape>
<gradient
android:endColor="@color/colored_tint"
android:startColor="@color/colored_tint"
android:angle="270" />
<stroke
android:width="0dp"
android:color="@color/colored_tint" />
<corners
android:radius="0dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:state_focused="true" android:drawable="@drawable/rounded_grayscale_pinstripe_button">
<shape>
<gradient
android:endColor="@color/colored_tint"
android:startColor="@color/colored_tint"
android:angle="270" />
<stroke
android:width="0dp"
android:color="@color/colored_tint" />
<corners
android:radius="0dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
<item android:drawable="@drawable/rounded_grayscale_pinstripe_button">
<shape>
<gradient
android:endColor="@color/colored_tint_dark"
android:startColor="@color/colored_tint_dark"
android:angle="270" />
<stroke
android:width="0dp"
android:color="@color/colored_tint_dark" />
<corners
android:radius="0dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp" …
Run Code Online (Sandbox Code Playgroud) 我已经找了一段时间的答案了,我承认我很困惑.我试图在我的应用程序中实现Twitter,并发现它有点挑战.似乎这样做的方法是将我的应用程序注册到Twitter(我已经这样做)作为浏览器应用程序.我不知道如何使用我的回调网址.我真的想回到我在应用程序中的当前活动,而不是被重定向到回调网址.我该怎么办呢?我很困惑......
我正在使用我的应用程序中Volley
提出POST
请求,在我的情况下,一个很好的响应是一个201
空洞的身体.我正在使用JSONRequest
,拨打电话.
我的问题是错误响应处理程序被调用,因为响应为空.
以下是我的要求:
Request request = new JsonRequest<Object>(Request.Method.POST, url, body, new Response.Listener<Object>() {
@Override
public void onResponse(Object response) {
}
}, new ErrorListener(context)) {
@Override
protected Response<Object> parseNetworkResponse(NetworkResponse response) {
Log.d(TAG, "success!!!!!!");
if (response.statusCode == 201)
mListener.resetPasswordWasSent();
return null;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
params.put("Content-Type","application/json");
params.put("Accept", "application/json");
return params;
}
};
requestQueue.add(request);
Run Code Online (Sandbox Code Playgroud)
我的parseNetworkResponse
函数获取调用,那么ErrorListener
,和onResponse
因为我得到一个方法永远不会命中NullPointerException
的ErrorListener …
现在Apple即将开始发售iPhone 5,我正在考虑扩展我的应用程序,以便它们在iPhone 5上全屏显示.我在模拟器上运行我的应用程序,甚至是UITableView
延伸到屏幕底部的应用程序,黑条显示在屏幕的顶部和底部.
这是我的问题:为iPhone 5扩展应用程序的最佳做法是什么?
我现在应该为3.5英寸和4英寸屏幕制作一个单独的笔尖,还是在代码中扩展所有内容?
我试图尽可能顺利地进行转换,所以我呼吁SO的知识让我知道为两个屏幕构建的最佳方法.
我知道这个问题与其他问题类似,但我无法找到我的代码出错的地方.我试图将当前日期转换为mm/dd/yyyy格式.这是我正在使用的:
NSDate *date = [[NSDate alloc]init];
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"mm/dd/yyyy"];
NSLog(@"%@", [formatter stringFromDate:date]);
Run Code Online (Sandbox Code Playgroud)
问题是这个月.每次运行此代码时,月份都不同.例如,我的第一次日期是32/11/2012,我刚刚运行它,它是55/11/2012.
有没有理由不断变化?日子和岁月似乎没问题.
谢谢.
我知道这是一个以前曾多次被问过的问题,但我似乎无法在我的代码中解决它.我有两个按钮,当按下一个按钮时,我希望将其保持在选定状态,反之亦然.我尝试过使用setSelected和setPressed,但我似乎无法让它工作.这是我正在使用的代码:
region_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
objects = category;
adap.notifyDataSetChanged();
proximity_button.setPressed(false);
region_button.setPressed(true);
}
});
proximity_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
objects = proximity;
adap.notifyDataSetChanged();
region_button.setPressed(false);
proximity_button.setPressed(true);
}
});
Run Code Online (Sandbox Code Playgroud)
编辑: 根据评论,我需要添加我有按钮的自定义xml背景,并希望保留当前的外观.
我正在使用json响应GSON
创建一个SugarRecord
对象.我正在使用的API返回一个名为"id"的字段,但"id"的类型是一个字符串,而不是long(后端使用mongo).
以下是我正在使用的代码:
Gson gson = new Gson(); // Or use new GsonBuilder().create();
NutritionPlan target = gson.fromJson(jsonObject.getJSONObject("nutrition_day").toString(), NutritionPlan.class);
Run Code Online (Sandbox Code Playgroud)
以下是我的json回复:
{
"nutrition_day": {
"id": "5342b4163865660012ab0000",
"start_on": "2014-04-08",
"protein_target": 157,
"sodium_limit": 2000
}
Run Code Online (Sandbox Code Playgroud)
有没有一种很好的方法来处理这种情况?我试过了
@Ignore
long id;
Run Code Online (Sandbox Code Playgroud)
和
@SerializedName("id")
String nutrition_plan_id;
Run Code Online (Sandbox Code Playgroud)
在我的模型中,但没有帮助.任何熟悉Sugar ORM的人,知道如何处理id
不长的领域?