小编Ash*_*hok的帖子

如何在iphone中找出当年的闰年

如何获得当前年份NSDate以及如何在Objective-C中查明该年份是否为闰年?

iphone xcode objective-c ipad ios

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

如何在ios中准备UIPickerView数月和数年?

我正在努力在iOS中准备UIPickerView数月和年份.

以下是我的代码.

viewdidload中:

//Array for picker view
monthsArray=[[NSMutableArray alloc]initWithObjects:@"Jan",@"Feb",@"Mar",@"Apr",@"May",@"Jun",@"Jul",@"Aug",@"Sep",@"Oct",@"Nov",@"Dec",nil];


NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy"];
NSString *yearString = [formatter stringFromDate:[NSDate date]];


yearsArray=[[NSMutableArray alloc]init];


for (int i=0; i<13; i++)
{
    [yearsArray addObject:[NSString stringWithFormat:@"%d",[yearString intValue]+i]];
}

myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;
[myPickerView selectRow:0 inComponent:0 animated:YES];
[self.view addSubview:myPickerView];
Run Code Online (Sandbox Code Playgroud)

Picker视图委托方法:

// tell the picker how many components it will have
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}

// tell the picker …
Run Code Online (Sandbox Code Playgroud)

objective-c uidatepicker uipickerview ios

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

在IOS中的keychainWrapper中存储NSArray或NSDictionary

keychainWrapper提供了存储NSString(如密码)的机制.

我还可以存储NSArrayNSDictionarykeychainWrapper

iphone objective-c ipad ios

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

在iOS中获取NSArray中匹配对象索引的最佳方法?

我有以下两个数组.

 NSArray *array1=[[NSArray alloc]initWithObjects:@"ABC",@"DEF", nil];
 NSArray *array2=[[NSArray alloc]initWithObjects:@"ABC",@"123",@"DEF",@"DEF", nil];
Run Code Online (Sandbox Code Playgroud)

现在我必须搜索每个array1的对象和array2,并需要获取匹配的索引.我的应用程序在array2中包含超过一千个对象.

请建议除了将第二个for循环放在第一个for循环之外的最佳方法

for (int i=0; i<array1.count; i++)
{
//Need to search the [array1 objectAtIndex:i] string in array2 and need to get the matched indexes into an array in best optimised way here.

    NSMutableArray *matchedIndexesArray=[[NSMutableArray alloc]init];
    NSString *stringToSearch=[array1 objectAtIndex:i];

    //here i can put another array like below to get the matched indexes..but is there any optimized way other than this for loop here? or is there any simple inbuilt method to get …
Run Code Online (Sandbox Code Playgroud)

objective-c nsarray ios

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

Mac OSX中eclipse中的凭据存储失败

当我使用我的凭据在mac中使用eclipse连接到tfs中的服务器项目时它连接没有任何问题,但当我在登录对话框中检查"保存密码"时它显示错误为

'凭据存储失败(无法保存凭据)'

有没有办法摆脱这个,因为每次打开eclipse时我都不想输入我的用户名和密码.

请参阅以下图像.

在此输入图像描述

.

.

在此输入图像描述

任何意见或建议将不胜感激.先感谢您.

eclipse macos tfs azure-devops

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

在iOS中使用UIImagePickerController时如何检测用户是否从库中选择图片或视频?

我在我的 ios 应用程序中使用 UIImagePickerController 为用户提供从照片库中选择照片或视频的选项。我将视频限制为 1 分钟。这是我的代码:

在按钮操作中:

- (void)getPictureOrVideoFromLibrary {

    CFStringRef mTypes[2] = { kUTTypeImage, kUTTypeMovie };
    CFArrayRef mTypesArray = CFArrayCreate(CFAllocatorGetDefault(), (const void**)mTypes, 2, &kCFTypeArrayCallBacks);
    imagePickerController.mediaTypes = (__bridge NSArray*)mTypesArray;
    CFRelease(mTypesArray);

    imagePickerController.videoMaximumDuration = 60.0f;
    imagePickerController.allowsEditing = YES;

    imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    [self presentViewController:imagePickerController animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

我想在照片库中显示图片和视频,所以我同时使用了kUTTypeImagekUTTypeMovie。这里我设置videoMaximumDuration60.0fallowsEditingtoYES因为我想将视频长度限制为 1 分钟。

我面临的问题:当用户从库中选择视频时没有问题,但如果用户从库中选择图片,我会遇到问题,图片上有一个矩形框。

选择器显示如下(有视频和图片)[截图1]:

在此输入图像描述

当用户选择视频时,它显示如下(它按预期工作):

在此输入图像描述

当用户选择图片时,它显示如下[屏幕截图2]:

在此输入图像描述

我不想在这里显示矩形裁剪框。

用户按下“选择”后,我将能够在委托方法“didFinishPickingMediaWithInfo”中检测它是照片还是视频。

但我想知道从截图1到截图2是照片还是视频。这样我就可以设置allowsediting为“否”来摆脱那个矩形框。

是否可以?

我不想将这两个选项显示为“从库中选择照片”、“从库中选择视频”。我只想显示一个选项“从库中选择照片或视频”。

有什么方法可以检测用户是否选择图片或视频,或者是否可以摆脱该矩形框?

有可能实现吗?

我需要您的宝贵建议。请帮我。提前致谢。

objective-c uiimagepickercontroller ios

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

Autolayout不会立即在iOS8-Xcode6中更新帧

我使用autolayoutXCode6.

我已将以下约束应用于a scrollview.

在此输入图像描述

我试图在iPhone 4Inchs设备的- viewDidLoad和 - viewWillAppear方法中访问此scrollview的框架.这里的问题是,scrollview的宽度在Log中显示为600.但是我正在使用4Ichs设备的宽度应为300 autolayout.似乎autolayout将在一段时间间隔后适用.它在 - viewDidAppear方法中显示正确的宽度为300.

有没有办法在 - viewDidLoad和 - viewWillAppear方法中访问原始帧?

提前致谢.

ios autolayout xcode6 ios8

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