小编Ram*_*hil的帖子

UIAlertController自定义字体,大小,颜色

我正在使用新的UIAlertController来显示警报.我有这个代码:

// nil titles break alert interface on iOS 8.0, so we'll be using empty strings
UIAlertController *alert = [UIAlertController alertControllerWithTitle: title == nil ? @"": title message: message preferredStyle: UIAlertControllerStyleAlert];


UIAlertAction *defaultAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: nil];

[alert addAction: defaultAction];

UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootViewController presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

现在我想更改标题和消息字体,颜色,大小等.什么是最好的方法呢?

编辑: 我应该插入整个代码.我为UIView创建了一个类别,我可以为iOS版本显示正确的警报.

@implementation UIView (AlertCompatibility)

+( void )showSimpleAlertWithTitle:( NSString * )title
                          message:( NSString * )message
                cancelButtonTitle:( NSString * )cancelButtonTitle
{
    float iOSVersion = [[UIDevice currentDevice].systemVersion floatValue]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview ios ios8 uialertcontroller

109
推荐指数
13
解决办法
16万
查看次数

Android:API级别VS. Android版本

我是Android开发的新手,我想知道版本和API级别之间的连接或区别.每个人指的是什么?当我决定为API 14或Android 4.0开发一些应用程序时,它意味着什么?

或者是另一个的子集?我根本没有区别,为什么有两个柜台?

谢谢

android

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

Socket vs SocketChannel

我试图了解SocketChannelsNIO.我知道如何使用常规套接字以及如何创建一个简单的每个客户端线程服务器(使用常规阻塞套接字).

所以我的问题:

  • 什么是SocketChannel?
  • 使用SocketChannel而不是Socket时,我获得了多少额外的东西.
  • 通道和缓冲区之间有什么关系?
  • 什么是选择器?
  • 文档中的第一个代码是A selectable channel for stream-oriented connecting sockets..那是什么意思?

我已经阅读了这个文档,但不知怎的,我没有得到它...

java sockets socketchannel

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

远程运行qemu(通过ssh)

我有一个我正在试验的服务器,有时我想在家工作,所以我安装了'ssh守护进程'(即'sshd'),我可以ssh到服务器.这很好用.但是当我尝试使用'qemu'在服务器上运行虚拟机时,我收到以下错误Could not initialize SDL(No available video device) - exiting.

是否可以通过ssh连接运行qemu?

注意,我不希望看到我正在启动的VM的可视界面.我只是想跑.

ssh qemu virtual-machine sshd

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

WPF中的Datagrid绑定

我知道这已经被问到了,但我已经完成了开发人员建议的几乎所有内容.

<DataGrid x:Name="Imported" VerticalAlignment="Top" DataContext="{Binding Source=list}"  AutoGenerateColumns="False" CanUserResizeColumns="True">
    <DataGrid.Columns>                
        <DataGridTextColumn Header="ID" Binding="{Binding Path=ID}"/>
        <DataGridTextColumn Header="Date" Binding="{Binding Path=Date}"/>
    </DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)

我试图在模态对话框中显示它并在模式对话框的构造函数中填充许可证列表.但仍然没有任何东西填充在数据网格中.

构造函数代码:

public diagboxclass()
{
    List<object> list = new List<object>();
    list = GetObjectList();
}

public class object
{
    string id;
    DateTime date;
    public string ID
    {
        get { return id; }
        set { id = value; }
    }
    public DateTime Date
    {
        get { return date; }
        set { date = value; }
    }
}
Run Code Online (Sandbox Code Playgroud)

你们认为与对象列表有关吗?

c# wpf xaml binding datagrid

20
推荐指数
3
解决办法
16万
查看次数

Material-UI - 为什么我应该使用 makeStyles 而不是内联样式?

Material-UI 中,有一个makeStyles函数可以用来获取自定义的 CSS-Styling。

如果我不在该特定 CSS 中使用主题,我应该使用它吗?

例如:

import React from "react";
import { TextField, Paper, Button, Box } from "@material-ui/core";

const classes = {
  paper: {
      backgroundColor: "#eee",
      marginLeft: "30%",
       marginRight: "30%"
  },
  textField: {
      backgroundColor: "#fff"
  },
  button: {
      backgroundColor: "green",
      marginLeft: 20
  }
};

const Ohne = () => {
  console.log(classes);
  return (
      <Paper style={classes.paper}>
      <Box>
          <TextField style={classes.textField} />
          <Button style={classes.button}>abc</Button>
      </Box>
      </Paper>
  );
};

export default Ohne;
Run Code Online (Sandbox Code Playgroud)

对象是:

{
    "paper": {
        "backgroundColor": "#eee", …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

17
推荐指数
1
解决办法
6331
查看次数

无状态和不可变之间有什么区别?

我经常听到"无国籍"和"不可改变"这个词.例如,HTTP是无状态协议,String对象是不可变对象.但我很难掌握两者之间的差异.当我创建无状态对象时,它不会在内部存储任何"状态"数据.如果我创建一个Immutable对象,它意味着它永远不会改变.

这是不是意味着同样的事情?

由于不可变对象不会改变,因此根据定义它不能具有状态.它永远是它.如果一个对象没有状态,则不能进行变异(根据定义).因此,并非所有无状态对象都是不可变和不可变对象无状态的吗?

什么可以是可变无状态对象或不可变状态对象的示例?

immutability stateless

16
推荐指数
2
解决办法
3233
查看次数

在linux中劫持实时时钟

我想编写一个劫持实时时钟(中断8)的LKM(Linux内核模块).所以我希望将中断设置为我的函数,并在某些时候将其发送回旧函数.

我试图使用该request_irq函数没有任何成功,可能是因为那里的内核函数不愿意共享中断(我猜这是一个很好的决定).
根据我发现的一些页面,我还尝试编辑IDT(中断描述符表).他们没有工作,大多数甚至没有编译,因为他们为内核2.6编写,我正在使用3.10.

这是一个简化的代码,我只是想让你知道我在做什么.

kpage =__get_free_page( GFP_KERNEL);
asm("sidt %0": : "m"(*idtr) : );
memcpy(kpage, idtr, 256*sizeof(kpage));
newidt = (unsigned long long *)(*(unsigned long*)(idtr+1));
newidt[8] = &my_function;
asm("lidt %0": "=m"(newidt):);
Run Code Online (Sandbox Code Playgroud)

我的所有尝试都是在分段故障的好时候结束,并且在内核崩溃的困难时期迫使我重新启动(幸运的是我使用虚拟机和快照).

那么我怎么能劫持实时中断所以它能完成我的工作呢?(然后将其发送回原始函数以执行.)

是一些很好的代码来改变IDT上的pagefault函数.我无法使它工作,因为它也是为内核2.6编写的.这个问题也值得研究.

要获得赏金,请发布工作代码,或者至少提供足够的信息以使其运行.

c linux interrupt kernel-module

16
推荐指数
1
解决办法
710
查看次数

如何正确清理视图模型?

我有一个视图模型,用作我的自定义控件的数据源.在视图模型的构造函数中,我设置了一个WMI ManagementEventWatcher并启动它.我的视图模型实现了IDisposable,所以我在Dispose方法中停止了观察者.

当我将自定义控件嵌入到窗口中,然后关闭窗口以退出应用程序时,它会抛出一个InvalidComObjectException说法"已经与其底层RCW分离的COM对象无法使用".这是因为我的观察者,如果我不创建它,就没有例外.没有关于异常的其他信息,例如堆栈跟踪等.

我的猜测是,有些东西保留了视图模型,直到观察者使用的线程终止但在观察者停止之前,我不知道如何处理这个问题.

有什么建议?谢谢康斯坦丁

public abstract class ViewModelBase : IDisposable, ...
{
    ...

    protected virtual void OnDispose() { }

    void IDisposable.Dispose()
    {
        this.OnDispose();
    }
}

public class DirectorySelector : ViewModelBase
{
    private ManagementEventWatcher watcher;

    private void OnWMIEvent(object sender, EventArrivedEventArgs e)
    {
        ...
    }

    protected override void OnDispose()
    {
        if (this.watcher != null)
        {
            this.watcher.Stop();
            this.watcher = null;
        }
        base.OnDispose();
    }

    public DirectorySelector()
    {
        try
        {
            this.watcher = new ManagementEventWatcher(new WqlEventQuery(...));

            this.watcher.EventArrived += new EventArrivedEventHandler(this.OnWMIEvent); …
Run Code Online (Sandbox Code Playgroud)

wpf wmi mvvm

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

WPF绑定:无法解析静态资源

我试图运行这个例子,但我遇到了绑定问题.

Designer会突出显示错误 The resource "monthCollection" could not be resolved

如何使用Utility.MonthCollection作为本地资源?

XAML部分:

<Window x:Class="FaceReport.WindowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Rapor" Height="402" Width="600" WindowState="Normal">
<Grid Name="gridMain" x:Uid="uidGridMain">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <ComboBox SelectedIndex="0" 
              DisplayMemberPath="Value" SelectedValuePath="Key" Margin="132,9,200,0"
              Grid.Row="3" Height="24" VerticalAlignment="Top" Name="cbBind" 

              ItemsSource="{Binding Source={StaticResource Utility.ReportForCollection},
                Path=Utility.ReportForCollection}"                   
              />
 </Grid>
 </Window>
Run Code Online (Sandbox Code Playgroud)

C#部分:

namespace FaceReport
{
internal class Utility
{
    public enum ReportFor
    {
        Choose,
        All,
        Group,
        Person
    }

    private static Dictionary<ReportFor, string> _dictReportFor;
    public static Dictionary<ReportFor, string> ReportForCollection
    {
        get
        {
            return _dictReportFor;
        }
    }

    static …
Run Code Online (Sandbox Code Playgroud)

c# wpf binding

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