小编Vik*_*ica的帖子

动态更改UITableView单元格分隔线颜色

任何人都可以给出示例代码如何动态更改UITableView单元格分隔线颜色?

iphone cocoa-touch objective-c uitableview uicolor

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

为什么不同的块动画常量具有相同的值?

UIViewAnimationOptions
用块动画视图的选项.

enum {
   UIViewAnimationOptionLayoutSubviews            = 1 <<  0,
   UIViewAnimationOptionAllowUserInteraction      = 1 <<  1,
   UIViewAnimationOptionBeginFromCurrentState     = 1 <<  2,
   UIViewAnimationOptionRepeat                    = 1 <<  3,
   UIViewAnimationOptionAutoreverse               = 1 <<  4,
   UIViewAnimationOptionOverrideInheritedDuration = 1 <<  5,
   UIViewAnimationOptionOverrideInheritedCurve    = 1 <<  6,
   UIViewAnimationOptionAllowAnimatedContent      = 1 <<  7,
   UIViewAnimationOptionShowHideTransitionViews   = 1 <<  8,

   UIViewAnimationOptionCurveEaseInOut            = 0 << 16,
   UIViewAnimationOptionCurveEaseIn               = 1 << 16,
   UIViewAnimationOptionCurveEaseOut              = 2 << 16,
   UIViewAnimationOptionCurveLinear               = 3 << 16,

   UIViewAnimationOptionTransitionNone            = 0 << 20,
   UIViewAnimationOptionTransitionFlipFromLeft    = 1 << 20,
   UIViewAnimationOptionTransitionFlipFromRight …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios4 ios

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

将图像保存到核心数据

我是一个与核心数据相关的新手.任何人都可以帮我提供正确的步骤/教程,展示如何将图像保存到核心数据及其回溯.我能够存储字符串数据,但我的应用程序在尝试保存图像时崩溃.保存:

DataEvent *event = (DataEvent *)[NSEntityDescription insertNewObjectForEntityForName:@"DataEvent"
                                                          inManagedObjectContext:managedObjectContext];
NSURL *url2 = [NSURL URLWithString:@"xxxxxxxxxxxxxxx SOME URL xxxxxxxxxxxx"];

NSData *data = [[NSData alloc] initWithContentsOfURL:url2];
imageSave=[[UIImage alloc]initWithData:data];
NSData * imageData = UIImageJPEGRepresentation(imageSave, 100.0);    
[event setValue:self.imageSave forKey:@"pictureData"];
Run Code Online (Sandbox Code Playgroud)

对于回顾:

 DataEvent *event = (DataEvent *)[eventsArray objectAtIndex:indexPath.row];
 UIImage *image = [UIImage imageWithData:[event valueForKey:@"pictureData"]];
 UIImageView *imageViewMainBackGround = [[UIImageView alloc] 
 CGRect rect3=CGRectMake(0,2,100.0,100.0); 
 imageViewMainBackGround.frame = rect3;
 [cell.contentView addSubview:imageViewMainBackGround];
 [imageViewMainBackGround release];
Run Code Online (Sandbox Code Playgroud)

cocoa-touch core-data objective-c uiimage ios

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

当前日期和时间 - NSDate

我需要显示当前的日期和时间.

我用过 ;

NSDate *currentDateNTime        = [NSDate date];
Run Code Online (Sandbox Code Playgroud)

我想拥有当前的日期和时间(应该显示系统时间而不是GMT时间).输出应采用NSDate格式而不是NSString.

例如;

    NSDate *currentDateNTime        = [NSDate date];
// Do the processing....

NSDate *nowDateAndTime = .....; // Output should be a NSDate and not a NSString
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios

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

使用sortUsingComparator对NSInteger进行排序

我正在尝试排序一个数组NSObjects(一个对象是一个类).对象类有几个变量,我想用它来排序数组中的对象,我用来排序的变量是类型的,NSString或者NSInteger我有信心我正在排序 NSStrings但是对于这个问题,我希望得到帮助分选NSInteger.

这是我用来对对象数组进行排序的方法,它接收一个NSMutableArray对象

- (NSMutableArray *)startSortingTheArray:(NSMutableArray *)unsortedArray
{
    [unsortedArray sortUsingComparator:^ NSComparisonResult(SearchResultItem *d1, SearchResultItem *d2) {
        NSInteger DoorID1 = d1.doorID;
        NSInteger DoorID2 = d2.doorID;
        NSComparisonResult result = [DoorID1 localizedCompare:DoorID2]; // Not sure how to sort these two integers
        if (result == NSOrderedSame) {
            NSString *handel1 = d1.handel;
            NSString *handel2 = d2.handel;
            result = [handel1 localizedCompare:handel2];
         }
Run Code Online (Sandbox Code Playgroud)

我不知道如何比较NSInteger,我已经读过我可以减去它自己的每个数字..如果数字是0那么它们是相等的还是+1/-1等它们不是......但不确定那是不是接近这个的最好方法.

任何帮助,将不胜感激.

cocoa-touch objective-c nsinteger ios

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

将视图从横向转换为纵向?

我已经开发了横向模式的应用程序,现在客户端要求在横向和纵向模式下构建.

如何将横向视图转换为纵向视图?

现在我将此代码用于Landscape View:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{

 return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

 }
Run Code Online (Sandbox Code Playgroud)

请帮我....

预付谢谢:)

cocoa-touch objective-c uiinterfaceorientation ios

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

匹配正则表达式与字符串(文件名)

我试图区分2个文件(NSString格式).据我所知,这可以通过比较和匹配正则表达式来完成.我拥有的2个jpg文件的格式是:

butter.jpg

黄油1.JPG

我的问题是我可以编写正则表达式来匹配上面的2个字符串吗?我已经搜索并找到了一个示例表达式,但我不确定它是如何阅读并认为它是错误的.

这是我的代码:

NSString *exampleFileName = [NSString stringWithFormat:@"butter-1.jpg"];

NSString *regEx = @".*l{2,}.*";    

NSPredicate *regExTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regEx];

if ([regExTest evaluateWithObject:exampleFileName] == YES) {
    NSLog(@"Match!");
} else {
    NSLog(@"No match!");
}
Run Code Online (Sandbox Code Playgroud)

编辑:

我尝试使用以下内容:

NSString *regEx = @"[a-z]+-[0-9]+.+jpg"; 
Run Code Online (Sandbox Code Playgroud)

尝试匹配:

NSString *exampleFileName = [NSString stringWithFormat:@"abcdefg-112323.jpg"];
Run Code Online (Sandbox Code Playgroud)

经测试:

abc-11.jpg(匹配)

abcsdas-.jpg(不匹配)

abcdefg11.(不匹配)

abcdefg-3123.jpg(匹配)

截至目前它是有效的,但我想消除它可能没有的任何机会,任何输入?

cocoa-touch objective-c ios

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

替换iOS中特定颜色的图像

我想用其他用户选择的颜色替换图像的特定颜色.在替换图像颜色时,我想保持原始颜色的渐变效果.例如,请参阅附加的图像. image1.png
image2.png

我试图用CoreGraphics这样做,我成功地取代了颜色.但是替换颜色不能保持图像中原始颜色的渐变效果.

有人可以帮我吗?CoreGraphics是正确的方法吗?提前致谢.

opengl-es core-graphics image-processing ios glkit

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

嵌套的Cocoa Touch框架

我正在寻找一种方法来生成具有子框架的框架,这些框架在运行时不会相互干扰.下最佳地描述了这个想法.

在此输入图像描述

假设每个版本的JSON Parser框架与另一个版本不兼容.

我一直在尝试大量的方法来实现上述目标,但每次都失败了.最有希望的是伞式框架,但Apple不仅不鼓励使用它(我不清楚为什么),而且它们似乎没有按预期工作.

会发生什么,如果我创建一个嵌入式框架A的应用程序,它本身嵌入了JSON Parser框架v1.0,似乎一切正常.但是,只要我将JSON Parser框架v3.0添加到App并将App链接到它,Framework A就会在运行时开始使用JSON Parser框架v3.0,而不是驻留在其中的v1.0.并假设他们是互不兼容,这可以打破框架.

添加框架B也是如此,但在运行时选择的实现似乎是随机的.

是否可以创建具有嵌入式JSON Parser框架v1.0的Framework A,并且在这种情况下可以安全使用?我发现很难相信没有办法实现这一点,但我找不到办法让它发挥作用,并开始想知道它是否实际上是可能的:(

xcode cocoa-touch frameworks ios

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

UICollectionView 在滚动之前未完全加载

我有一个集合视图,我想在其中显示每小时的天气。我似乎在加载单元格时遇到问题,并且由于某种原因向前滚动然后向后滚动完全加载单元格。在我滚动集合视图之前,所有约束都不起作用,并且一个标签不显示其信息。

\n\n

滚动之前\n滚动之前

\n\n

滚动后(这就是我想要的单元格的样子)\n滚动后(这就是我想要的单元格的样子)

\n\n
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {\n    // #warning Incomplete implementation, return the number of sections\n    return 1\n}\n\n\nfunc collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {\n    // #warning Incomplete implementation, return the number of items\n    return newhourlyWeather.count\n}\n\nfunc collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {\n    let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! hourlyWeatherCell\n\n    // Configure the cell\n\n    let hWeather = newhourlyWeather[indexPath.row]\n\n    if let HourlyTemp = hWeather.temperatureh {\n        cell.temperatureHLabel.text = "\\(HourlyTemp)\xc2\xba"\n    }\n\n    if let HourlyTime = …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios uicollectionview uicollectionviewcell swift

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