小编Tec*_*ain的帖子

在 Node js 中使用多个 api 文档进行 swagger?

我已经为一个项目提供了 API 版本。所以它有两个文件夹 v1 和 v2,它们有不同的 api。现在为了实现 v1 和 v2 的 swagger,我在app.js中编写了以下代码。

// Swagger definition
// You can set every attribute except paths and swagger
const swaggerDefinition = {
    swagger: '2.0',
    info: {
        // API informations (required)
        title: 'API', // Title (required)
        version: '1.0.0', // Version (required)
        description: 'Used for  api documentation', // Description (optional)
    },
    host: `localhost:3000`, // Host (optional)
    basePath: '/v1', // Base path (optional)
};

// Options for the swagger docs
const optionsV1 = { …
Run Code Online (Sandbox Code Playgroud)

node.js swagger swagger-ui swagger-2.0

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

如何在android中使用volley发送params数组

我正在开发一个应用程序,它将大量数据发送到server.Now我想使用volley发送一个params数组到php页面.但是我无法发送它.

将params添加为Array的代码.

String[] arr =new String[7];
    for(int i=1;i<=7;i++)
    {
        arr[i]="questionId_"+i+"_"+"ans_"+i;

    }
    HashMap<String ,String[]> params=new HashMap<String, String[]>(7);
    params.put("params", arr);
Run Code Online (Sandbox Code Playgroud)

向服务器发出请求的代码

RequestQueue que=Volley.newRequestQueue(this);

     final ProgressDialog dialog = new ProgressDialog(HealthMyHistory.this);
     dialog.setTitle("Please Wait");
     dialog.setMessage("Sending Data");
     dialog.setCancelable(false);
     dialog.show();


    CustomJobjectRequest jsObjRequest = new CustomJobjectRequest(Method.POST, url, params, new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response)
                {
                    dialog.dismiss();



                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError response) {

                    dialog.dismiss();
                    Toast.makeText(getApplicationContext(), "Unable to Send Data!"+" "+response.toString(), Toast.LENGTH_SHORT).show();
                }
            });
    que.add(jsObjRequest);

}



Problem is in CustomJobjectRequest there is no …
Run Code Online (Sandbox Code Playgroud)

java android json android-volley

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

如何在iOS中为UITextField提供填充?

我想从左边填充填充到textfield.我已经在textfield中添加了一个背景图像,因为textfield中的文本总是从最左边开始.我尝试了下面的解决方案,但这对于太多文本字段不起作用.

    UIView *fieldEmail = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
    self.txt_fname.leftViewMode = UITextFieldViewModeAlways;
    self.txt_fname.leftView     = fieldEmail;
Run Code Online (Sandbox Code Playgroud)

请建议我一些简单的解决方案,其中我不必创建一个单独的视图来给出填充.

问题中接受的答案对我不起作用. 使用UITextBorderStyleNone为UITextField设置填充

iphone objective-c ipad ios

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

在iOS中创建了重复的单元格?

我在iOS中创建了一个自定义单元格.在自定义单元格中有很多标签.对于少数标签,第一个和第四个自定义单元格的数据总是相同的.我的数据源数组中共有5条记录.现在有这些问题我面对.

  1. 当数组中有4条记录时,为什么索引行的单元格只被调用两次.
  2. 第一行和第四行的数据始终相同.

请告诉我如何解决这个问题.

码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"cell for row called %d",(int)[arr_post count]);
    //define variables here
    NSMutableAttributedString *mutableAttributeStr;
    NSAttributedString *attributeStr;
    static NSString *CellIdentifier = @"homeCell";
    float x_pos;
   HomeCell *cell = [self.table_view
                     dequeueReusableCellWithIdentifier:CellIdentifier
                     forIndexPath:indexPath];

    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    //get the post data
    Post *user_post=[arr_post objectAtIndex:indexPath.row];
    cell.tv_post.text=user_post.post_description;
    cell.tv_post.font = [UIFont fontWithName:user_post.font_family size:[user_post.font_size floatValue]];
    cell.label_name.text=user_post.post_title;
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [formatter dateFromString:user_post.modification_date];
    if([user_post.post_image isEqualToString:@"none"] && [user_post.post_video isEqualToString:@"none"])
    {
        x_pos=cell.tv_post.frame.origin.x;
        cell.tv_post_leading_space.constant=-(x_pos);
        [cell.img_post setHidden:true];
    } …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

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

如何在heightForRowAtIndexPath中获取单元格?

我已经在我的应用程序中创建了自定义单元格.我想要获取每个单元格HeightForRowAtIndexPath.请告诉我如何在此方法中获取自定义单元格.我已尝试此代码但这会导致无限循环并最终导致应用程序崩溃.

HomeCell *cell=(HomeCell *)[tableView cellForRowAtIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)

编辑:

我试过这个,但它给我的单元格高度为零.

-   (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *cellIdentifier = @"HomeCell";
    HomeCell *cell = (HomeCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    float tv_view_height=cell.tv_post.frame.size.height;
    float like_count_height=cell.label_like_count.frame.size.height;
    float first_comment_height=cell.first_comment.frame.size.height;
    float second_comment_height=cell.second_cmment.frame.size.height;
    float third_comment_height=cell.third_comment.frame.size.height;

    Post *user_post=[arr_post objectAtIndex:indexPath.row];
    float comment_count=[user_post.comment_count intValue];
    if(comment_count<=0)
    {
        first_comment_height=0;
        second_comment_height=0;
        third_comment_height=0;


    }
    else if(comment_count==1)
    {
        second_comment_height=0;
        third_comment_height=0;

    }
    else if(comment_count==2)
    {

        third_comment_height=0;
    }
     float like_count=[user_post.like_count intValue];
    if(like_count<=0)
    {

        like_count_height=0;
    }
    float total_height=tv_view_height+like_count_height+first_comment_height+second_comment_height+third_comment_height;
    NSLog(@"total heigh is %f'",total_height);
    return total_height;
}
Run Code Online (Sandbox Code Playgroud)

请告诉我哪个是最好的方法?

iphone objective-c uitableview ipad ios

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

Multilple iOS设备的动态布局?

我正在iOS中开发一个应用程序.早期我正在为单独的iOS设备创建单独的故事板,但现在我使用自动布局和大小类来支持多个iOS设备.我创建了一个登录屏幕.我没有指定任何宽度或高度观点但我已经给出了领先的空间和尾随空间,也是顶部和底部空间.这是示例图像 在此处输入图像说明![在此输入图像说明

在图像中,图像的大小根据iPad的尺寸进行扩展,但我不希望它的图像看起来太大.我想要与iPhone中相同的高度和重量比.请建议怎么办?

iphone xcode objective-c storyboard ios

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

ios 8.4模拟器在xcode 6.4中是非常大的尺寸?

我刚刚将我的xcode从6.2升级到6.4.早先iphone的模拟器尺寸很好.但现在iphone 5,5s,4s的尺寸非常大.现在我在水平和垂直两侧都有滚动条.我不知道为什么尺寸太大.如何解决这个问题?

iphone xcode ipad ios xcode6

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

无法通过移动它们重新排列UICollectionView中的单元格?

我有UICollectionView,我正在显示自定义单元格.我试图通过长按手势移动单元格,但它根本不起作用.

我已经按照教程但它不适合我.请告诉我该怎么做?

长按手势

-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{

    NSLog(@"long press geture called");
    switch(gestureRecognizer.state)
    {
        case UIGestureRecognizerStateBegan:
            p = [gestureRecognizer locationInView:self.collection_view];
          gesture_indexPath = [self.collection_view indexPathForItemAtPoint:p];
        [self.collection_view beginInteractiveMovementForItemAtIndexPath:gesture_indexPath];
            NSLog(@"state began called");

                     break;

        case UIGestureRecognizerStateChanged:

        //    collectionView.updateInteractiveMovementTargetPosition(gesture.locationInView(gesture.view!))
            [self.collection_view updateInteractiveMovementTargetPosition:[gestureRecognizer locationInView:[gestureRecognizer view]]];
            NSLog(@"state changed called");
        case UIGestureRecognizerStateEnded:
            [self.collection_view updateInteractiveMovementTargetPosition:p];
                  NSLog(@"state changed called");
        default:
            [self.collection_view cancelInteractiveMovement];
    }
}
Run Code Online (Sandbox Code Playgroud)

方法被覆盖

-(void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
    NSLog(@"Move at index path called");
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ipad ios

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

如何获得属性字符串的字符串范围?

我有字符串作为2/42。这里2和42是动态的,现在我想设置/42为字符串的上标。我无法找到的范围/42。请告诉我如何迅速找到范围?

range nsattributedstring ios swift swift4

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

无法更新订购者配置中的batchtimeout?

我创建了一个结构网络,它运行良好。我想更新oderer配置,例如batchtimeout在运行中的网络中。我已按照教程在运行时更新通道配置。本教程适用于添加新组织。但是当我更新订购者配置时,我得到了如下错误

错误:状态发生意外:BAD_REQUEST-将配置更新应用于现有通道“ mychannel”时出错:授权更新:错误验证DeltaSet:未满足[Value] / Channel / Orderer / BatchTimeout的策略:隐式策略评估失败-0子-符合政策,但此政策要求满足“管理员”子政策中的1个

我从所有组织管理员(例如org1和org2)中选择了信封.pb文件。请帮助我。

注意:为此,我使用了fabric-samples第一网络。

编辑:我已经用org1和org2签署了pb文件。我还通过导出以下变量与订购者签署了文件

CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin\@example.com/msp/

CORE_PEER_ADDRESS=orderer.example.com:7050

CORE_PEER_LOCALMSPID=OrdererMSP

CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
Run Code Online (Sandbox Code Playgroud)

日志

11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc4 Manager Channel/Orderer looking up path []
2019-11-28 09:13:57.207 UTC [policies] Manager -> DEBU cc5 Manager Channel/Orderer has managers OrdererOrg
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc6 == Evaluating *policies.implicitMetaPolicy Policy /Channel/Orderer/Admins ==
2019-11-28 09:13:57.207 UTC [policies] Evaluate -> DEBU cc7 This is an implicit meta policy, it will trigger other …
Run Code Online (Sandbox Code Playgroud)

blockchain hyperledger hyperledger-fabric hyperledger-chaincode

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