小编MNM*_*MNM的帖子

更改UIAlertcontroller背景颜色

好吧,我有这个警告,我正在使用它,我希望它的背景是黑色而不是灰色的样子.我已设法更改标题和消息的文本颜色,但不更改背景颜色.那么我想要的颜色.我已将其更改为绿色蓝色和白色,但不是黑色.当我尝试将其更改为黑色时,它会变为灰色.任何建议都会有所帮助并受到赞赏.我试过这里如何更改UIAlertController的背景颜色?这就是我到达现在的位置.

这就是我现在要做的事情:

func showAlert(title:String, message:String) {

    //Set up for the title color
    let attributedString = NSAttributedString(string: title, attributes: [
        NSFontAttributeName : UIFont.systemFontOfSize(15), //your font here,
        NSForegroundColorAttributeName : UIColor.whiteColor()
        ])
    //Set up for the Message Color
    let attributedString2 = NSAttributedString(string: message, attributes: [
        NSFontAttributeName : UIFont.systemFontOfSize(15), //your font here,
        NSForegroundColorAttributeName : UIColor.whiteColor()
        ])

    let alert = UIAlertController(title: title,message: message, preferredStyle: .Alert)

    alert.setValue(attributedString, forKey: "attributedTitle")
    alert.setValue(attributedString2, forKey: "attributedMessage")
    //alert.view.tintColor = UIColor.whiteColor()
    let dismissAction = UIAlertAction(title: "Dismiss", style: .Destructive, handler: nil) …
Run Code Online (Sandbox Code Playgroud)

objective-c ios swift uialertcontroller

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

LinkedList checkForComodification错误java

好的,我在这里要做的是让一个方法"运行"一个给定数量的"时间"的过程,这个所有接缝在一定程度上工作,但它不断给出这些例子.这是它给出的第一个执行

     Exception in thread "main" java.util.ConcurrentModificationException
Run Code Online (Sandbox Code Playgroud)

然后在exicutio它给出了这个

    at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761)
at java.util.LinkedList$ListItr.next(LinkedList.java:696)
at parta.PartA.runQueueOne(PartA.java:273)
Run Code Online (Sandbox Code Playgroud)

我不知道我在做什么错在这里我应该让这个并发或什么?如果是这样的话?我认为链表本质上是同步的?也许那就是我搞砸了.

那么这里的任何方式是我使用的方法:

 public static void runQueueOne(LinkedList<MyProcess> q1, LinkedList<MyProcess> q2, LinkedList<MyProcess> q3, LinkedList<MyProcess> q4, int ct)
{
     System.out.println("Running Level One Queue");


     for(MyProcess p : q1)
     {
         if(p.name.equalsIgnoreCase(q1.getFirst().name))
         {
             //add 3 millsedonds to the service time
             q1.getFirst().serviceTimeTotal += 3;
             System.out.println(q1.getFirst().name + " is running");

         }else
         {
             //add 3 millseconds to wait time fr the un busy one
             p.waitTimeTotal+=3;
         }
     }

      for(MyProcess p : q2)
     {
         p.waitTimeTotal+=3;
     }
      for(MyProcess p …
Run Code Online (Sandbox Code Playgroud)

java asynchronous linked-list concurrentmodification

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

在swift中按下按钮后,在segue之前执行一些代码

我有一个按钮进入另一个视图.我想在segue移动之前执行一些代码.我面临的问题是在代码有机会完成之前,segue会转到另一页.因此,在更改视图之前,不会更改"用户"默认值中的值.我的问题是我如何才能运行代码并在完成后让segue开火?这是我到目前为止:

 @IBAction func onLogoutClick(sender: AnyObject) {
    //clear all url chache 
    NSURLCache.sharedURLCache().removeAllCachedResponses()
    //null out everything for logout
    email = ""
    password = ""
    self.loginInformation.setObject(self.email, forKey: "email")
    self.loginInformation.setObject(self.password, forKey: "password")
    self.loginInformation.synchronize()
    //self.view = LoginView
}
Run Code Online (Sandbox Code Playgroud)

ios uistoryboardsegue swift xcode7

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

(HTTPLog)-Static:isSBSettingEnabled false error和app正在关闭

我看了很多,到目前为止,我收集的是这是一个三星问题,涉及HttpUrlConnection由于某种原因无法在三星上工作.那么我该如何解决这个问题呢.我无法理解别人说要做些什么来解决这个问题.该应用程序在模拟器上完美运行,但在我用于测试的三部手机上死机.其中一个samsongs是S4活跃的Android 5.0.1 API 21

我正在使用相同的http调用来下载其他数据,这很好用.就在我尝试访问登录页面时,它甚至都不会访问它.我不认为我的代码有任何问题,因为它在模拟器上运行得很好.

这就是输出错误给我的感谢感谢您对此的任何帮助.

W/InstanceID/Rpc: Found 10063
E/ViewSystem: ViewRootImpl #2 Surface is not valid.
D/AbsListView: Get MotionRecognitionManager
I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
I/System.out: (HTTPLog)-Static: isShipBuild true
/System.out: (HTTPLog)-Thread-35911-714863967: SmartBonding Enabling is false, 
    SHIP_BUILD is true, log to file is false, DBG is false
/System.out: (HTTPLog)-Static: isSBSettingEnabled false
Run Code Online (Sandbox Code Playgroud)

java android http samsung-mobile

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

动态规划斐波那契算法

我正在研究一种计算斐波那契数的算法并获得了它的伪代码,但我无法计算出运行需要多少时间。我认为它的运行时间为 O(n) 但不太确定。这是代码:

Algorithm Fast-Fibonacci(n)
Let fib[0] and fib[1] be 1.
for each i from 2 to n, do:
    Let fib[i] be fib[i - 2] + fib[i - 1].
end of loop
return fib[n].
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

algorithm time-complexity

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

使用swiftyjson和swift解析嵌入式json

所以我试图使用swiftyjson从这个json文件中解析出这个嵌入值,但我无法弄清楚如何从json中获取嵌入的东西.

这是我到目前为止所做的,它适用于获取json的上层,但不适用于嵌套项.我需要的主要内容是名称的项目部分和项目中创建的值.

  if let data = json.dataUsingEncoding(NSUTF8StringEncoding) {
        let newJson = JSON(data: data)
        myBarcode = newJson["barcode_id"].stringValue
        myName = newJson["name"].stringValue
        myTotalPointsEarned = newJson["total_points_earned"].stringValue
        myPointsEarned = newJson["points_available_to_spend"].stringValue
        myRank = newJson["rank"].stringValue
        myId = newJson["id"].stringValue
        //new json arrary to get the items and dates
        var myHistory = newJson["order_history"].arrayValue
        print("\n My Hist \n" , myHistory)

        //FAIL
        //var myItems = newJson["items"].stringValue
        //print("\n My Items \n" , myItems)
    }
Run Code Online (Sandbox Code Playgroud)

这是我试图解析的json文件

{
 "id" : "xxx",
 "name" : "xfgsfsdfs",
 "total_points_earned" : null,
 "points_available_to_spend" : null,
 "rank" : null,
 "barcode_id" …
Run Code Online (Sandbox Code Playgroud)

json ios swift swifty-json

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

Pytorch 试图使 NN 收到无效的参数组合

我正在尝试使用 pytroch 构建我的第一个 NN,但遇到了问题。

类型错误:new() 收到了无效的参数组合 - 得到了 (float, int, int, int),但需要以下之一:* (torch.device device) * (torch.Storage storage) * (Tensor other) * (tuple整数大小,torch.device 设备)*(对象数据,torch.device 设备)

现在我知道这是什么意思,因为我没有将正确的类型传递给方法或 init。但我不知道我应该通过什么,因为它看起来对我来说是正确的。

def main():
#Get the time and data
now = datetime.datetime.now()
hourGlassToStack = 2 #Hourglasses to stack
numModules= 2        #Residual Modules for each hourglass
numFeats = 256      #Number of features in each hourglass
numRegModules = 2   #Depth regression modules

print("Creating Model")
model = HourglassNet3D(hourGlassToStack, numModules, numFeats,numRegModules).cuda()
print("Model Created")
Run Code Online (Sandbox Code Playgroud)

这是创建模型的主要方法。然后调用这些方法。

class HourglassNet3D(nn.Module):

  def __init__(self, nStack, nModules, …
Run Code Online (Sandbox Code Playgroud)

python-3.x pytorch

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

使用 CSV 数据文件 Sklearn 进行简单线性回归

过去几天我一直在尝试这个,但运气不佳。我想做的是使用 sklearn 进行简单的线性回归拟合和预测,但我无法获取用于模型的数据。我知道我没有正确地重塑我的数据,我只是不知道该怎么做。
对此的任何帮助将不胜感激。我最近收到此错误 发现输入变量的样本数量不一致: [1, 9] 这似乎意味着 Y 有 9 个值,而 X 只有 1。我认为这应该是相反的,但是当我打印 X 时,它给出了 CSV 文件中的一行,但 y 给出了 CSV 文件中的所有行。对此的任何帮助将不胜感激。

这是我的代码。

filename = "E:/TestPythonCode/animalData.csv"

#Data set Preprocess data
dataframe = pd.read_csv(filename, dtype = 'category')
print(dataframe.head())
#Git rid of the name of the animal
#And change the hunter/scavenger to 0/1
dataframe = dataframe.drop(["Name"], axis = 1)
cleanup = {"Class": {"Primary Hunter" : 0, "Primary Scavenger": 1     }}
dataframe.replace(cleanup, inplace = True)
print(dataframe.head())
#array = dataframe.values
#Data splt
# …
Run Code Online (Sandbox Code Playgroud)

python numpy pandas scikit-learn

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

将字符串解析为整数并将其存储在数组中

好的,所以我有点难过如何正确地做这件事.我有一些方法,现在我腰部深.所以我想做的就是解析每行上带有一堆二号的文本文件,就像这样

1 10
2 12 
3 13 
Run Code Online (Sandbox Code Playgroud)

等等....

每个人被一个空间分开.我已经得到了这么远,我甚至得到它为对象中的变量分配正确的数字.我的事情是它继续覆盖数组,并不会用文本文件中的数据填充其余部分.我认为如果打印出阵列,它应该打印出文本文件.感谢您的帮助

public static void main(String[] args) {

    Process [] pArray;
    //just need to have 10 Process
    pArray = new Process [10];

    //delimiter to parse string
    String delimiter = " ";
    String[] tokens;
    tokens = new String [10];

    /*
     * save this for input handeling
    Scanner input = new Scanner( System.in );
    System.out.println("Enter the Text file for data set");
    String fileDestination = input.next();
    * */

    //get data from the file
    File file = …
Run Code Online (Sandbox Code Playgroud)

java arrays string split

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

Java中对象的优先级队列

你好我有点失去了优先级队列和比较器.我真的没有看到如何在java中制作比较器所以我所拥有的是给我一个错误,而我所读到的内容对我没有帮助 http://www.tutorialspoint.com/java/java_using_comparator.htm 这个帖子游戏我一些想法,但我仍然坚持如何做它 如何使用PriorityQueue?

我所拥有的是一个创建具有优先级,到达时间和完成时间的对象的类.我还有一些优先级队列来放置它们.当我开始时,我将它们放入到达队列中以对它们进行排序,然后查看哪一个进入并将其放入队列中.但是当我尝试将第二个添加到到达队列时,它会失败并抛出异常.我首先要做的是将所有进程添加到到达队列,然后对它们进行排序,使得到达时间最短的进程将是到达队列中的第一个并进入队列一.感谢您的帮助

    //the comparator
    Comparator<Integer> comparator = new Comparator();
    //priority queues
    //only needs 10 elements to  hold
    PriorityQueue one = new PriorityQueue(10, comparator);
    PriorityQueue two = new PriorityQueue(10, comparator);
    PriorityQueue three = new PriorityQueue(10, comparator);
    PriorityQueue four = new PriorityQueue(10, comparator);
    PriorityQueue arrival = new PriorityQueue(10, comparator);

    //put all processes in arrival queue
    arrival.add(p1);
    arrival.add(p2);
    arrival.add(p3);
    arrival.add(p4);
    arrival.add(p5);
    arrival.add(p6);
    arrival.add(p7);
    arrival.add(p8);
    arrival.add(p9);
    arrival.add(p10);
Run Code Online (Sandbox Code Playgroud)

java priority-queue comparator

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

如何使用 Alamofire 完全禁用 URLCache

在 Swift 中使用 Xcode 7.3 iOS 9.2 没有任何可怕的 Objective C 我已经研究了一段时间并且现在已经在这个街区周围三遍了。我在这里尝试过这篇文章,但没有奏效 http://www.mzan.com/article/32199494-alamofire-how-remove-cache.shtml

我也尝试使用苹果文档,但这太糟糕了,我无法理解 if。

所以我正在做的是对我的服务器进行两次 Alamofire 调用。一是测试登录信息的凭据,看输入是否正确。二是下载并返回客户信息以供查看。当我第一次调用它时,两者都工作正常。问题是当我退出应用程序时,我会清除页面中的所有用户信息。但是当我在同一个会话中登录时,它会调用第一个正确的,所以如果我输入了错误的用户名或密码,即使我第一次登录正确,它也会返回 false。但是当我下载客户数据时,它一直在下载我第一次访问用户信息时的旧信息。它使用新的用户名和密码,但仍然下载旧的东西。

这是我的登录和注销功能:

//MARK: ButtonControllers
@IBAction func onLoginClick(sender: AnyObject) {

    errorMessageUI.text = "Checking Creditials"
    email = userNameInput.text!
    password = passwordInput.text!
    buildLoginUrl = checkLoginUrl + emailTag + email + passwordTag + password
    print(buildLoginUrl)
    print("Login Cred")
    checkLoginCredentials(buildLoginUrl)
}

@IBAction func onLogoutClick(sender: AnyObject) {

    //null out everything for logout
    email = ""
    password = ""
    self.loginInformation.setObject(self.email, forKey: "email")
    self.loginInformation.setObject(self.password, forKey: "password")
    self.loginInformation.synchronize()
    performSegueWithIdentifier("logoutSegue", sender: self)
    //self.view = …
Run Code Online (Sandbox Code Playgroud)

nsurlcache ios nsurlsession swift alamofire

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

树莓派和OpenCV无法安装libhdf5-100

我正在尝试降级并安装 OpenCv 需要安装的旧版本软件包。

因此,当我尝试安装它时,出现此错误:

pi@raspberrypi:~ $ sudo apt-get install libhdf5-100
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libhdf5-100 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libhdf5-103

E: Package 'libhdf5-100' has no installation candidate
Run Code Online (Sandbox Code Playgroud)

我需要 103 上的 libhdf5-100 才能正确安装和运行 opencv。我正确安装了 Opencv,但在尝试导入时出现此错误。

(mypi) pi@raspberrypi:~ $ python
Python 3.5.4 (default, Sep …
Run Code Online (Sandbox Code Playgroud)

linux opencv raspbian raspberry-pi3

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

将字符串转换为iso日期格式

所以我试图将字符串转换为日期的 iso 格式。这是我要转换的字符串 "2016-07-05 02:14:35.0" 我希望以这种格式使用 iso 8601 "2016-07-05T02:14:35.0"

到目前为止我有这个

 DateTimeFormatter format = DateTimeFormat.forPattern("YYYY-MM-DDTHH:mm:sszzz");
     new LocalDate();
    LocalDate newDate = LocalDate.parse(created,format);
     created = newDate.toString();
Run Code Online (Sandbox Code Playgroud)

但它给了我这个例外

ERROR: Illegal pattern component: T; nested exception is java.lang.IllegalArgumentException: Illegal pattern component: T
Run Code Online (Sandbox Code Playgroud)

我跟着例子,我不知道我在这里做错了什么。任何帮助,将不胜感激。

java datetime iso string-formatting jodatime

0
推荐指数
1
解决办法
9504
查看次数