小编Bur*_*rak的帖子

如何在Django中相对于项目路径设置LOCALE_PATH?

在开发环境中,我将语言环境路径设置为:

LOCALE_PATHS = (
'/Users/***/Documents/Projects/**/Server/Django/**/locale',
)
Run Code Online (Sandbox Code Playgroud)

但是,当我将其部署到服务器时,区域设置路径将被更改.

我怎么处理这个?

django django-i18n

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

在Django中,如何根据用户组来限制某些url访问?

在我的Django应用程序中,我有3种类型的角色(组)

超级用户帐户管理员ShopAdmin

我希望超级用户可以访问每个URL,但是其他2个管理员不能访问/ su / * URL。

我怎样才能做到这一点?

django

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

使用yum时如何修复"错误解释器"错误?

$ yum install httpd-devel
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

python yum

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

如何用动画从UITableView中删除行?

我在从表视图中删除行时遇到问题.当按下行中的删除按钮时,我正在使用下面的代码:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:control.tag-100 inSection:0];
[resultList removeObjectAtIndex:indexPath.row];
[resultView beginUpdates];
[resultView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[resultView endUpdates];
//[resultView reloadData];
Run Code Online (Sandbox Code Playgroud)

第一行已成功删除,但随后索引不正确.因此,当我删除最后一行时,它会给出索引超出范围的异常.

细胞生成代码是:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"personalizeTableCell";

    PersonalizeCell *cell = (PersonalizeCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
        cell = [[PersonalizeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];        
    cell.title.text = @"text";
    cell.rateView.tag = indexPath.row + 100;
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

更新:

    for (NSInteger j = 0; j < [venuesTableView numberOfSections]; ++j)
    {
        for (NSInteger i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

uitableview delete-row

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

为什么SDWebImage在加载后不在单元格中显示图像?

我正在使用SDWebImage.在我的表中,每行都有图像和标签.

在此输入图像描述

如您所见,无法看到图像.

但是当我回到父视图控制器并再次来到这里时,它们会被显示出来.

在此输入图像描述

我使用的代码是:

[cell.imageView setImageWithURL:[NSURL URLWithString:serie.image] placeholderImage:[UIImage imageNamed:@"placeholder.png"]  options:SDWebImageRefreshCached];
Run Code Online (Sandbox Code Playgroud)

那么,我哪里错了?

uitableview ios sdwebimage

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

在iOS中滚动后,如何获取滚动视图可见的矩形框?

t滚动后,我无法在滚动视图中获得可见矩形的坐标。因此,当我想在可见矩形中添加子视图时,便不能。我怎样才能做到这一点?

uiscrollview ios

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

无法在Android/Java中解析来自MongoDB的日期字符串

我正在尝试解析来自MongoDB的日期(2015-06-25T00:00:00.000Z).

try {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
    Date date = format.parse("2015-06-25T00:00:00.000Z");
    return new Date().after(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

java android date mongodb

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

如何在GridView布局中将TextView添加到ImageView中?

我需要一个GridView,但在每个网格中,它上面/内部都会有一个ImageView和TextView.

它将类似于每个网格中的项目图像,以及图像上项目的名称.

我是:

    public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) { // if it's not recycled, initialize some
                                // attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setPadding(0, 0, 0, 0);
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);

    TextView nameView = new TextView(mContext);
    nameView.setText("Name");
    nameView.setTextSize(20);

    parent.addView(nameView);

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

在我的网格视图适配器中.但我不能在这里添加它.我也尝试在ImageView中添加它,但由于它不是ViewGroup,我无法实现.

更新:

public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = LayoutInflater.from(mContext);
    ViewHolder holder;

    if (convertView == …
Run Code Online (Sandbox Code Playgroud)

android android-gridview

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

如何删除左UIBarButtonItem的背景

我试图删除左UIBarButtonItem背景的背景.

的UIBarButtonItem

我的图像只是带有线条的图标.但是有黑色背景.我的代码是:

paneViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menuicon"] style:UIBarButtonItemStylePlain target:self action:@selector(navigationPaneBarButtonItemTapped:)];
paneViewController.navigationItem.leftBarButtonItem.tintColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

更新:

UIImage *myImage = [UIImage imageNamed:@"menuicon"];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:myImage forState:UIControlStateNormal];
myButton.showsTouchWhenHighlighted = YES;
myButton.frame = CGRectMake(0.0, 0.0, myImage.size.width, myImage.size.height);

[myButton addTarget:self action:@selector(navigationPaneBarButtonItemTapped:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:myButton];
paneViewController.navigationItem.leftBarButtonItem = leftBarButton;
Run Code Online (Sandbox Code Playgroud)

这对我有用.谢谢

uibarbuttonitem uibarbuttonitemstyle ios

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

为什么点击手势识别器会识别其父视图中视图的水龙头?

我有一个UIView和一个轻敲手势识别器:

UIImageView *tabView = [[UIImageView alloc] initWithFrame:CGRectMake(41, 145, 702, 100)];
tabView.image = [UIImage imageNamed:@"inactive_tab"];
tabView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleFingerTap =
[[UITapGestureRecognizer alloc] initWithTarget:self
                                        action:@selector(handleSingleTap:)];
[tabView addGestureRecognizer:singleFingerTap];
[self.scrollView addSubview:tabView];
Run Code Online (Sandbox Code Playgroud)

我在scrollview上添加了另一个视图:

[self.scrollView addSubview:self.activeTab];
Run Code Online (Sandbox Code Playgroud)

activeTab超过inactiveTap.当我点击activeTap时,手势识别器会发射,我想不要发生这种情况.我怎么能避免这个?

uigesturerecognizer ios

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

使用AFNetworking下载文件时出现内存警告

更新:

我写了一个非常简单的下载代码:

NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString  *documentsDirectory = [paths objectAtIndex:0];

NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxxx.s3.amazonaws.com/products/ipad/xxxx.mp4"]];
for(int i=0; i<4; i++){
    NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,[NSString stringWithFormat:@"xxxx%d.mp4",i]];
    AFDownloadRequestOperation* operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:filePath shouldResume:YES];
    operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
    [operation setShouldOverwrite:YES];
    [operation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile) {
        NSLog(@"%f", ( totalBytesRead / (float)totalBytesExpected));
    }];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"finished");
    } failure:^(AFHTTPRequestOperation *operation, …
Run Code Online (Sandbox Code Playgroud)

memory-leaks memory-management ios afnetworking afnetworking-2

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

我怎样才能找到POEdit错误

我在POEdit中收到重复的消息定义错误,我无法从该目录更新.

POEdit不显示详细信息,并且错误中的行号不匹配.

我怎么能找到错误的?

Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:2791: duplicate message definition...
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:65: ...this is the location of the first definition
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:2827: duplicate message definition...
Sat Mar 11 16:51:31 2017: /var/folders/qt/cg8qlhc159v9s15kmhy1h4440000gn/T/poeditgGtdFw/1input.po:1530: ...this is the location of the first definition
Sat Mar 11 16:51:31 2017: /Users/burakkilic/Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin/msgmerge: found 2 fatal errors
Sat Mar 11 16:51:31 2017: Entries in the catalogue are probably incorrect.
Sat Mar 11 16:51:31 2017: Updating the catalogue failed. …
Run Code Online (Sandbox Code Playgroud)

poedit

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

如何在Angular 4中初始化表单组?

我有以下ngOnInit方法:

ngOnInit() {
    this.countries = this.sharedService.getCountries();
    this.shopService.getCurrentShopFromCache().then(shop => {
        this.shop = shop;
        this.myFormGroup = this.fb.group({
            name: [this.shop.name[this.shop.defaultLanguage.code], [Validators.required]],
            address: [this.shop.address.address],
            city: [this.shop.address.city],
            state: [this.shop.address.state],
            country: [this.shop.address.country, [Validators.required]],
            phone: [this.shop.phone],
            email: [this.shop.email],
            website: [this.shop.social.website],
            twitter: [this.shop.social.twitter],
            facebook: [this.shop.social.facebook],
            instagram: [this.shop.social.instagram],
            foursquare: [this.shop.social.foursquare]
        });
    }
    );
}
Run Code Online (Sandbox Code Playgroud)

我越来越

formGroup expects a FormGroup instance. Please pass one in.
Run Code Online (Sandbox Code Playgroud)

我哪里错了?

更新:

 <form *ngIf="shop" class="m-form m-form--fit m-form--label-align-right" [formGroup]="myFormGroup" novalidate>
                       ... 
Run Code Online (Sandbox Code Playgroud)

angular2-formbuilder angular

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