小编MTA*_*MTA的帖子

UIDatePicker返回错误的NSDate

我在我的应用程序中使用UIDatePicker,当我选择的日期:

NSDate *date = picker.date;
Run Code Online (Sandbox Code Playgroud)

picker.date 在我选择的日期前一天返回.

知道为什么会这样吗?

iphone objective-c uidatepicker

5
推荐指数
2
解决办法
7731
查看次数

MySql获取行数

我尝试从表中获取行数:

        string commandLine = "SELECT COUNT(*) FROM client";

        using (MySqlConnection connect = new MySqlConnection(connectionStringMySql))
        using (MySqlCommand cmd = new MySqlCommand(commandLine, connect))
        {
            connect.Open();

            int count = (int)cmd.ExecuteScalar();

            return count;
        }
Run Code Online (Sandbox Code Playgroud)

我得到了例外:

Specified cast is not valid.
Run Code Online (Sandbox Code Playgroud)

知道我怎么解决它?

.net c# mysql

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

MySql从列和计数中选择所有数据

我正在使用此命令选择列中的所有行:

SELECT city From Users
Run Code Online (Sandbox Code Playgroud)

有了这个,我从我的桌子上得到了所有的城市.

现在我想选择所有列数据和每个列数据.例如:

New York 20
Los angeles 46
London 35
Run Code Online (Sandbox Code Playgroud)

这个命令应该是什么?

.net c# mysql sql iis

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

XmlSerializer add attribute

I have this item Class :

public class Movie
{
    public string VideoId { get; set; }
    public string Title { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

And i have List<Movie> of this items and i use this code to Serialize to xml file:

string fileName = index + ".xml";
string serializationFile = Path.Combine(dir, fileName);

XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;

using (var writer = XmlWriter.Create(serializationFile, settings))
{
    var serializer = new XmlSerializer(typeof(List<Movie>));
    serializer.Serialize(writer, tmpList);
}
Run Code Online (Sandbox Code Playgroud)

And this is the …

.net c# winforms

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

带有限制的SQL查询

我在SQL Server中有这个表:

ID   | videoid  | title
=========================
1    | id1      | title1
2    | id2      | title2
3    | id3      | title3
Run Code Online (Sandbox Code Playgroud)

我想创建在标题行中搜索的select方法:

SELECT * FROM [movie].[dbo].[movies] 
WHERE title like '%' + '%s' + '%'
Run Code Online (Sandbox Code Playgroud)

而且我正在寻找类似MySQL的限制,从SELECT结果中我将能够得到0-20,21-40,41-60结果.

对此查询有何帮助?

我试图使用LIMIT 0, 10,我收到此错误:

Could not find stored procedure 'LIMIT'.
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server

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

在 React Native 中检测静默模式

有没有办法使用react-native知道手机(iPhoneAndroid)是否处于静音模式?

react-native

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

LinearLayout 在小型设备中没有响应

我的 Android 应用程序中有一个布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/player_background"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    tools:context=".Fragments.PlayerFragment">

    <ProgressBar
        android:id="@+id/progress_bar_player"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="5dp"
        android:theme="@style/ProgressBarStyle"
        android:visibility="invisible" />

    <TextView
        android:id="@+id/title_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:text="Title"
        android:textColor="@color/white"
        android:textSize="24dp" />

    <ImageView
        android:id="@+id/view_imageview"
        android:layout_width="280dp"
        android:layout_height="280dp"
        android:layout_marginTop="10dp"
        android:background="@color/white" />

    <TextView
        android:id="@+id/status_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:gravity="center"
        android:text="Status"
        android:textColor="@color/white"
        android:textSize="20dp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <ImageButton
            android:id="@+id/play_pause_btn"
            android:layout_width="70dp"

            android:layout_height="70dp"
            android:layout_centerHorizontal="true"
            android:background="@drawable/round_button"
            android:gravity="center_vertical|center_horizontal"
            android:padding="20dp"
            android:scaleType="fitCenter"
            android:src="@drawable/play_btn" />

        <ImageButton
            android:id="@+id/sleep_timer_btn"
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:layout_marginLeft="30dp"
            android:layout_toRightOf="@+id/play_pause_btn"
            android:background="@drawable/round_button"
            android:gravity="center_vertical|center_horizontal"
            android:padding="20dp"
            android:scaleType="fitCenter"
            android:src="@drawable/sleep_btn" />

        <ImageButton
            android:id="@+id/share_btn" …
Run Code Online (Sandbox Code Playgroud)

java android android-layout kotlin android-studio

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

用javascript播放声音

我想在每一行创建一个带有字符串和按钮(播放声音)的表格,每个按钮播放不同的声音.

我想用这种方法做到这一点:

<script>
function EvalSound(soundobj) {
  var thissound=document.getElementById(soundobj);
  thissound.Play();
}
</script>

<embed src="success.wav" autostart=false width=1 height=1 id="sound1"
enablejavascript="true">
Run Code Online (Sandbox Code Playgroud)

这是按钮:

<form>
<input type="button" value="Play Sound" onClick="EvalSound('sound1')">
</form>
Run Code Online (Sandbox Code Playgroud)

问题是我想要在这里:

<input type="button" value="Play Sound" onClick="EvalSound('sound1')">
Run Code Online (Sandbox Code Playgroud)

写入文件URL而不是'sound1',可以这样做吗?或者我需要更改代码中的其他内容?

编辑:

我像这样构建脚本:

<script>
   function EvalSound(soundobj) {
   var embed = document.createElement('embed');
   embed.setAttribute('width',1);
   embed.setAttribute('height',1);
   embed.setAttribute('src',soundobj);
   embed.setAttribute('autostart', false);
   embed.setAttribute('enablejavascript', true);
   embed.Play();
   }
</script>
Run Code Online (Sandbox Code Playgroud)

并称之为:

<form>
    <input type="button" value="Play Sound" onClick="EvalSound('sound url')">
</form>
Run Code Online (Sandbox Code Playgroud)

它仍然没有发出声音.

html javascript html5

4
推荐指数
1
解决办法
4万
查看次数

从String中删除空格

我有很多看起来像这样的字符串:

current            affairs
Run Code Online (Sandbox Code Playgroud)

我想让字符串成为:

current affairs
Run Code Online (Sandbox Code Playgroud)

我尝试使用,Trim()但它不会做这个工作

c#

4
推荐指数
2
解决办法
248
查看次数

禁用滑块键盘事件

我的XAML中有这个滑块:

<Slider Width="250" 
        Margin="0,-2,0,0"
        VerticalAlignment="Center"
        Name="TimeSlider"
        Maximum="100"
        Thumb.DragStarted="MouseEnterSlider"
        Thumb.DragCompleted="MouseLeaveSlider"
        ValueChanged="TimeSlider_ValueChanged" />
Run Code Online (Sandbox Code Playgroud)

我注意到如果按下键盘上的上/下箭头键,滑块将改变其值.

我尝试用以下方法禁用它:

TimeSlider.IsEnabled = false;
Run Code Online (Sandbox Code Playgroud)

但这会完全禁用滑块.有没有办法禁用向上/向下箭头键?

.net c# wpf

4
推荐指数
1
解决办法
1744
查看次数