小编Rom*_*ski的帖子

多个NSPredicate

我正在尝试在我的CoreData实体食谱中准备多个搜索.有一些参数,我想准备提取.

食谱属性:

@property (nonatomic, retain) NSNumber * difficulty;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * code; //like identifier
@property (nonatomic, retain) NSNumber * prepTime;
Run Code Online (Sandbox Code Playgroud)

成分是一个单独的实体与成分列表.

Join实体包含ingredientCode,recipeCode,count.

getArrayOfJoinDataWithIngredients获取连接实体并返回包含一些输入成分的配方代码的NSArray .

这是我的代码:

- (IBAction)callRecipeFetch:(id)sender
{
    NSString *predicateString = @"";

    NSArray *codes = [[NSArray alloc] init]; codes = nil;
    if ([paramController.ingredientsForSearchArray count] > 0) {
        NSMutableArray *ingredientsArray = [[NSMutableArray alloc] init];
        for (Ingredients *ingredient …
Run Code Online (Sandbox Code Playgroud)

nspredicate ios

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

如何在UITableViewCell中为UIButton设置Action

我有XIB文件TimerCell.xibUITableViewCell.在cellForRowAtIndexPath的其他类中,我初始化为UITableViewCell:

    static NSString *CellIdentifier = @"cellTimer";
    TimerCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        //cell = [[TimerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TimerCell"owner:self options:nil];
        cell = [nib objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

在我的TimerCell中,我有两个UILabel和一个UIButton.对于这个按钮,我想设置一些方法的动作.

我怎样才能做到这一点?以及如何UILabel实时显示来自我的背景倒数计时器的数据?

uitableview ios

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

改变push-segue或其动画风格

是关于push-segue的问题,请转到iOS应用中的"主页".

一切正常,但push-segue只有一个"从右到左"的动画类型.在iPad应用程序中它并不美观.那么,我怎么能改变动画类型,例如,"淡化"?

或者可能有其他方式来准备我想要的东西.

animation ios segue

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

UICollectionView和自定义UICollectionReusableView不起作用

我正在尝试UICollectionReusableViewUICollectionView标题中使用自定义(具有自己的类和XIB).但是在获取标题后的数据后,我什么都没有.

我的步骤:

  1. viewDidLoad中注册类:

     [self.collectionView registerClass:[CollectionViewHeader class] 
      forSupplementaryViewOfKind: UICollectionElementKindSectionHeader 
      withReuseIdentifier:@"HeaderView"];
    
    Run Code Online (Sandbox Code Playgroud)
  2. 试图显示:

    - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
    {
    UICollectionReusableView *reusableView = nil;
    
    if (kind == UICollectionElementKindSectionHeader) {
        CollectionViewHeader *collectionHeader = [self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
    
        NSInteger section = [indexPath section];
        id <NSFetchedResultsSectionInfo> sectionInfo = [fetchRecipes sections][section];
        collectionHeader.headerLabel.text = @"bla-bla-bla";
    
        reusableView = collectionHeader;
    }
    
    return reusableView;
    }
    
    Run Code Online (Sandbox Code Playgroud)

谁能告诉我什么是错的?)感谢您的任何建议

xib ios uicollectionview uicollectionreusableview

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

如何使用SuperObject lib在Delphi中创建JSON文件?

我正在使用Delphi 2010和superobject库.

我已经了解如何解析json文件,但我不知道如何创建json?

算法是:

  1. 解析JSON并在TStringGrid中加载
  2. 添加数据
  3. 将所有TStringGrid数据保存到json.

需要一些例子.

谢谢.

delphi json superobject

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

如何正确设置UIView的alpha?[iOS的]

我有UIView很多子视图(UILabel,UITextView等).

如果设置alpha 0.6到主视图所有子视图都采用此alpha.

如何分别设置主视图的alpha?

alpha uiview ios

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

UICollectionView仅显示数据集中的第一个项目

有两个实体(Department < - >> Employee).

该部门有4名员工.当我获取此部门中的所有员工时,我的日志窗口显示:

CoreData:注释:总获取执行时间:4行0.0017秒.

一切安好.

UICollectionView只显示第一名员工4次.例如:

Employee1,Employee1,Employee1,Employee1

代替

Employee1,Employee2,Employee3,Employee4

我在cellForItemAtIndexPath中有一些错误:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"cellRecipe";    
    collectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

    Employee *emp = [array_ objectAtIndex:indexPath.item];
    cell.name.text = emp.name;
    cell.image.image = emp.thumbImg;

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

array_是fetch之后的NSMutableArray

core-data ios uicollectionview

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

CoreData多对多关系

如何在CoreData中使用多对多关系进行操作?例如:

我有2个实体 - 食谱和配料

CoreData将它们像Recipes << - >> Ingredients链接起来.现在我需要为食谱中的每种成分添加属性"Count".我该怎么做?

谢谢

many-to-many core-data

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

iOS中的InApp-Purchases didFailWithError:

使用Ray的好教程 ......

为什么我无法从设备加载InApp-Purchases(didFailWithError: calls)列表,但在模拟器中我可以?

EDITED

如果我在设备didFailWithError:方法调用上运行app :

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {

NSLog(@"Cannot load the list of products...");
NSLog(@"Error - %@", error.description);
_productsRequest = nil;

_completionHandler(NO, nil);
_completionHandler = nil;

}
Run Code Online (Sandbox Code Playgroud)

这是错误描述:

Error - Error Domain=NSURLErrorDomain Code=-1004 "Cannot connect to iTunes Store" UserInfo=0x1cdb19c0 {NSLocalizedDescription=Cannot connect to iTunes Store}
Run Code Online (Sandbox Code Playgroud)

解决了

我很抱歉,但问题在于代理.一些网站(包括Apple的网站)已经关闭.

现在它有效!谢谢!

in-app-purchase ios

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

如何获得字符串中的行数?

总体而言,我从JSON对中获取了一个包含“ \ n”符号的字符串。例如,

“我可以看到地球如何养育其草皮,\\\ n \ n \ n \ n \ n \ n \ n \ s \ n \ n \ s \ n \ n \ s \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ n \ …

string lua coronasdk

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

如何通过UIButton标记获取UITableView的行和节?

UITableViewCell哪些包含UIButton.

在我的cellForRowAtIndexPath中:

cell.toCartBtn.tag = indexPath.row;
[cell.toCartBtn addTarget:self
           action:@selector(toCart:) forControlEvents:UIControlEventTouchDown];
Run Code Online (Sandbox Code Playgroud)

toCart方法中,我需要通过tapped按钮标记获取行和节.我该怎么做?

uitableview ios

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

UICollectionView不显示单元格

UIViewController哪些包含UICollectionView.还有UICollectionViewCell自己的类和XIB(CurrentCell.h,CurrentCell.m,CurrentCell.xib).

在我的UIViewController.h:

@property (strong, nonatomic) IBOutlet UICollectionView *collection;
Run Code Online (Sandbox Code Playgroud)

在我的UIViewController.m:

@synthesize collection;
Run Code Online (Sandbox Code Playgroud)

viewDidLoad中:

[self.collection registerClass:[CurrentCell class] forCellWithReuseIdentifier:@"cellCurRecipe"];

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(120, 90)];
[flowLayout setSectionInset:UIEdgeInsetsMake(5, 10, 5, 10)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
[self.collection setCollectionViewLayout:flowLayout];
Run Code Online (Sandbox Code Playgroud)

cellForItemAtIndexPath中:

static NSString *CellIdentifier = @"cellCurRecipe";    
CurrentCell *cell = (CurrentCell *)[self.collection dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];   
Recipes *recipe = [currRecipesArray objectAtIndex:indexPath.item];  
[cell.image setImage: recipe.image]; 
return cell;
Run Code Online (Sandbox Code Playgroud)

但是:如果我直观地点击了单元格didSelectItemAtIndexPath方法调用.

EDITED

现在一切正常!

我忘了在CurrentCell.m中初始化单元格:

- (id)initWithFrame:(CGRect)frame …
Run Code Online (Sandbox Code Playgroud)

ios uicollectionview uicollectionviewcell

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