小编use*_*164的帖子

反应原生 TouchableOpacity onPress 不适用于 Android

TouchabelOpacity 在 iOS 上运行良好,但 onPress 方法对我来说在 Android 上不起作用。

我的本机版本:0.57.4

我的代码:

const initDrawer = navigation => (
  <TouchableOpacity
    style={{ left: 16 }}
    onPress={() => onPressDrawerButton(navigation)}
  >
    <Ionicons name="ios-menu" color="white" size={30} />
  </TouchableOpacity>
);
Run Code Online (Sandbox Code Playgroud)

android react-native touchableopacity touchablehighlight

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

CATransition黑色阴影

我想要做的是为我的模态呈现视图控制器创建自定义过渡效果(仅用于解除它).我只是希望它看起来像原始但更慢.问题是我的模态呈现VC和VC之间的黑色阴影我想回去.

到目前为止,这是我的代码:

let transition: CATransition = CATransition()
transition.duration = 0.6
transition.type = kCATransitionReveal
transition.subtype = kCATransitionFromBottom
self.view.window!.layer.add(transition, forKey: nil)
self.dismiss(animated: false, completion: nil)
Run Code Online (Sandbox Code Playgroud)

catransition ios swift

7
推荐指数
0
解决办法
310
查看次数

给定日期和今天日期之间的C++天数

我有一个叫做的函数int differenceDatesInDays(string& date).此函数应获取字符串值作为日期(YYYY-MM-DD)并将其与今天日期进行比较.

我不知道STL中是否有东西,我找不到匹配的算法.我刚刚发现boost有一个解决方案,但我不想使用boost.

所以,到目前为止这是我的代码:

int differenceDatesInDays(string& date) {
    string year = date.substr(0, 4);
    string month = date.substr(5,2);
    string day = date.substr(8, string::npos);

    int y = stoi(year);
    int m = stoi(month);
    int d = stoi(day);

    time_t time_now = time(0);
    tm* now = localtime(&time_now);

    int diffY = y - (now->tm_year + 1900);
    int diffM = m - (now->tm_mon + 1);
    int diffD = d - (now->tm_mday);

    int difference = (diffY * 365) + (diffM * 30) + diffD;

    return …
Run Code Online (Sandbox Code Playgroud)

c++ time boost date c++11

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

C++ std :: sort on std :: vector <Object> - 错误太多

我有两个类TempFile和Year.TempFile得到一个温度为过去130年的.txt文件.构造函数读取此文件并将数据存储在a中std::vector<Year>.现在我想添加一个排序函数,它以降序显示每年的平均温度.但是当我struct定义我的比较(第三个参数std::sort)时,我得到的错误太多了.我也试图超载>-operator.也没用.

class TempFile {
public:
    TempFile(std::string temp_file); // read from .txt file and push_back() the data into std::vector<Year> _years. 
    //The vector and constructor are working fine.

    int get_number_years() const;

    std::vector<Year> get_vector() const;
    void sort_descending() const;
private:
    std::vector<Year> _years;
    struct descending
    {
        bool operator() (const Year& y1, const Year& y2)
        {
            return (y1.get_average_temp() > y2.get_average_temp());
        }
    } temp_descending;
};

int TempFile::get_number_years() const
{
    return _years.size();
}

std::vector<Year> …
Run Code Online (Sandbox Code Playgroud)

c++ sorting swap vector

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