如何获得当前年份NSDate以及如何在Objective-C中查明该年份是否为闰年?
我正在努力在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) keychainWrapper提供了存储NSString(如密码)的机制.
我还可以存储NSArray或NSDictionary在keychainWrapper?
我有以下两个数组.
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) 当我使用我的凭据在mac中使用eclipse连接到tfs中的服务器项目时它连接没有任何问题,但当我在登录对话框中检查"保存密码"时它显示错误为
'凭据存储失败(无法保存凭据)'
有没有办法摆脱这个,因为每次打开eclipse时我都不想输入我的用户名和密码.
请参阅以下图像.

.
.

任何意见或建议将不胜感激.先感谢您.
我在我的 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)
我想在照片库中显示图片和视频,所以我同时使用了kUTTypeImage和kUTTypeMovie。这里我设置videoMaximumDuration为60.0f和allowsEditingtoYES因为我想将视频长度限制为 1 分钟。
我面临的问题:当用户从库中选择视频时没有问题,但如果用户从库中选择图片,我会遇到问题,图片上有一个矩形框。
选择器显示如下(有视频和图片)[截图1]:

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

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

我不想在这里显示矩形裁剪框。
用户按下“选择”后,我将能够在委托方法“didFinishPickingMediaWithInfo”中检测它是照片还是视频。
但我想知道从截图1到截图2是照片还是视频。这样我就可以设置allowsediting为“否”来摆脱那个矩形框。
是否可以?
我不想将这两个选项显示为“从库中选择照片”、“从库中选择视频”。我只想显示一个选项“从库中选择照片或视频”。
有什么方法可以检测用户是否选择图片或视频,或者是否可以摆脱该矩形框?
有可能实现吗?
我需要您的宝贵建议。请帮我。提前致谢。
我使用autolayout在XCode6.
我已将以下约束应用于a scrollview.

我试图在iPhone 4Inchs设备的- viewDidLoad和 - viewWillAppear方法中访问此scrollview的框架.这里的问题是,scrollview的宽度在Log中显示为600.但是我正在使用4Ichs设备的宽度应为300 autolayout.似乎autolayout将在一段时间间隔后适用.它在 - viewDidAppear方法中显示正确的宽度为300.
有没有办法在 - viewDidLoad和 - viewWillAppear方法中访问原始帧?
提前致谢.
ios ×6
objective-c ×5
ipad ×2
iphone ×2
autolayout ×1
azure-devops ×1
eclipse ×1
ios8 ×1
macos ×1
nsarray ×1
tfs ×1
uidatepicker ×1
uipickerview ×1
xcode ×1
xcode6 ×1