小编Ind*_*ore的帖子

DataContractJsonSerializer解析iso 8601日期

我有一个json,它有日期2012-06-07T00:29:47.000,必须反序列化.但是

 DataContractJsonSerializer serializer = new DataContractJsonSerializer(type);
 return (object)serializer.ReadObject(Util.GetMemoryStreamFromString(json));
Run Code Online (Sandbox Code Playgroud)

我得到以下异常

There was an error deserializing the object of type System.Collections.Generic.List`1
[[MyNameSpace.MyClass, MyNameSpace, Version=1.0.4541.23433, Culture=neutral, PublicKeyToken=null]].
 DateTime content '2012-06-07T00:29:47.000' does not start with '\/Date(' and end with ')\/' as required for JSON
Run Code Online (Sandbox Code Playgroud)

它在Windows Mobile 7中工作,但相同的代码在Windows 8中不起作用.
它期待日期格式\/Date(1337020200000+0530)\/而不是2012-06-07T00:29:47.000.

它是否需要自定义序列化,如果是,那么如何?我不能使用JSON.NET我必然会使用DataContractJsonSerializer我不能改变JSON的格式,因为相同的JSON用于Android.
我是.net的新手.谢谢.

.net c# windows-phone-7 windows-8 .net-4.5

8
推荐指数
1
解决办法
6106
查看次数

内部移动std :: vector元素和QVector

有两个向量std :: vectorQVector.我们必须检查插入时"移位"元素的方式.(用五个元素构造两个向量并插入零元素)我有这个代码:

#include <QVector>
#include <QTextStream>

struct MoveTest
{
    int i;

    MoveTest()                       {}
    MoveTest(const MoveTest& other)  {QTextStream(stdout) << "constr copy" << endl;}
    MoveTest(MoveTest &&other)       {QTextStream(stdout) << "constr move" << endl;}
    ~MoveTest()                      {}

    inline MoveTest&    operator=   (const MoveTest& other) {QTextStream(stdout) << "copy" << endl;}
    inline MoveTest&    operator=   (MoveTest &&other)      {QTextStream(stdout) << "move" << endl;}
};

int main(int argc, char *argv[])
{
    QTextStream(stdout) << "std::move:" << endl;
    MoveTest t1;
    MoveTest t2(std::move(t1));
    t1 = std::move(t2);

    QTextStream(stdout) << "QVector:" …
Run Code Online (Sandbox Code Playgroud)

c++ qt gcc stl c++11

7
推荐指数
1
解决办法
2231
查看次数

将子高度或宽度设置为父控件与android中的"match_parent"相同

我有一个包含网格的页面,在该网格中有一个地图.但是我无法将地图的大小设置为与网格大小相同.虽然我可以在代码中设置它

MyMap.Height = LayoutRoot.ActualHeight;
MyMap.Width = LayoutRoot.ActualWidth;
Run Code Online (Sandbox Code Playgroud)

但是如何在xaml中设置它.

<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"
    x:Class="MapSample.MainPage"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Red">
        <maps:Map x:Name="MyMap" HorizontalAlignment="Left" VerticalAlignment="Top" Center="47.6097, -122.3331" ZoomLevel="10"/>
    </Grid>

</phone:PhoneApplicationPage>
Run Code Online (Sandbox Code Playgroud)

c# xaml windows-8 windows-phone-8

7
推荐指数
1
解决办法
8432
查看次数

使用Parameter在cocos2d中初始化场景

我正在尝试在cocos2d(版本0.99.5)中初始化一个场景,并希望传入一个参数.在这种情况下,参数是对应于级别编号的int值.场景类本身是一个子类CCLayer,我用节点类方法初始化它:

GameScene *scene = [GameScene node];  //GameScene subclass of CCLayer
Run Code Online (Sandbox Code Playgroud)

我有一个自定义的init方法,它接受变量"level",如下所示:

- (id) initWithGameLevel:(int)level {
    if ((self = [super init])){
        // etc 
    }
}
Run Code Online (Sandbox Code Playgroud)

只是想知道:我在创建自己的initWithX方法的过程中是否偏离基础,以及如何使用级别整数初始化场景?

objective-c cocos2d-iphone ios

6
推荐指数
1
解决办法
3942
查看次数

MySQL:每天的总和

我有一张桌子如下:

datetime (datetime)  count (int)
2012-12-27 09:22:15    5
2012-12-27 18:20:15    4
2012-12-27 23:19:15    3
2012-12-26 13:45:15    8
2012-12-26 04:56:15    7
2012-12-25 01:50:15    2
2012-12-25 12:02:15    1
Run Code Online (Sandbox Code Playgroud)

在MySQL中,如何查询是否希望每天返回总和(计数)和结果,如下所示:

2012-12-27    12
2012-12-26    15
2012-12-25    3
Run Code Online (Sandbox Code Playgroud)

mysql sql select

6
推荐指数
1
解决办法
9112
查看次数

iOS获取jpg文件的宽度高度

在我的iOS应用程序中,我正在从网上下载jpeg图像,我想知道如何找到图像的正确宽度和高度,以便我可以在我的iOS应用程序中正确显示它.

例如,
在此输入图像描述

如何获得此jpg图像的宽度和高度?

iphone jpeg image objective-c ios

6
推荐指数
1
解决办法
8779
查看次数

片段中未显示Android EditText键盘

我加入EditTextFragment,但EditText即使点击我也没有显示键盘EditText.

这是我的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">

    <EditText
        android:id="@+id/setting_nickname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="8"
        android:gravity="right"
        android:hint="Samantha"
        android:textColorHint="@color/nav_selected"
        android:textSize="14dp"
        android:textColor="@color/nav_selected"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" >
    </EditText>

    <EditText
        android:id="@+id/setting_country"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="8"
        android:gravity="right"
        android:hint="Samantha"
        android:textColorHint="@color/nav_selected"
        android:textSize="14dp"
        android:textColor="@color/nav_selected"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" >
    </EditText>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我试着听听 EditText

final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
edit_nickname.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        imm.showSoftInput(edit_nickname, 0);

        //edit_nickname.requestFocus();  --> fail
        //imm.showSoftInput(edit_nickname, InputMethodManager.SHOW_IMPLICIT);  --> fail
        //imm.showSoftInput(edit_nickname, InputMethodManager.SHOW_FORCED);  --> fail …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-softkeyboard android-edittext android-fragments

6
推荐指数
1
解决办法
1397
查看次数

不调用UITableView委托

我有一个带外部委托控制器的tableview.尽管内容表视图数组已经很好地填充,
numberOfSectionsInTableView:并且 -tableView: numberOfRowsInSection:被调用,
但是-tableView: cellForRowAtIndexPath:没有被调用.

发布的表视图以这种方式设置:

CompeticionViewController.h

....

@property (retain, nonatomic) IBOutlet UITableView *calendarioTable;
@property (strong, nonatomic)  calendarioViewController *calendarioController;

....

calendarioTable = [[UITableView alloc] init];

            calendarioController  = [[calendarioViewController alloc] init];

            [calendarioTable setDelegate:calendarioController];

            [calendarioTable setDataSource:calendarioController];

            calendarioController.calendarioArray = [[NSMutableArray alloc] init];

            [calendarioController.calendarioArray addObjectsFromArray: self.calendarioarray];

            [calendarioTable reloadData];
Run Code Online (Sandbox Code Playgroud)

编辑:

calendarioViewController.m

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return [calendarioArray count];

}
Run Code Online (Sandbox Code Playgroud)

非常感谢

objective-c ios5

5
推荐指数
1
解决办法
2414
查看次数

我是否需要取消订阅ac#metro应用程序中的活动?

我已经订阅各种事件OnNavigatedTo

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    Loaded += Screen_Loaded;
}
Run Code Online (Sandbox Code Playgroud)

我没有取消订阅此活动.不需要此页面时是否会导致内存问题?

c# microsoft-metro windows-8

5
推荐指数
1
解决办法
226
查看次数

适用于iOS 6的新Facebook SDK在iOS 5中存在崩溃问题

在iOS 6中,新的Facebook SDK在iOS 5上运行但崩溃

错误是这样的,

dyld: Library not loaded:/System/Library/Frameworks/AdSupport.framework/AdSupport
Reason: image not found
Run Code Online (Sandbox Code Playgroud)

facebook ios ios5

5
推荐指数
1
解决办法
309
查看次数