有一个应用程序,可以拍照,然后上传到服务器.将它编码为base 64并将其通过XMLRPC传递给我的php服务器.
我想获取从UIImagePickerController委托返回的NSDictionary信息
-(void) imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info
Run Code Online (Sandbox Code Playgroud)
并将其转换为NSData,以便我可以对其进行编码.
那么,我如何将NSDictionary转换为NSData?
iphone objective-c nsdictionary uiimagepickercontroller nsdata
我的UICollectionView中有多个部分按"datasetType"分组.
我还为每个部分都有一个自定义的UICollectionViewCell.
如何确定方法中UICollectionViewCell需要哪个自定义cellForItemAtIndexPath?
我的第一个是基于[sectionInfo name]:
id sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:indexPath.section];
if ([[sectionInfo name] isEqualToString:@"DatasetA"]) {
DatasetACell *datasetACell = [collectionView dequeueReusableCellWithReuseIdentifier:datasetACellIdentifer forIndexPath:indexPath];
DatasetA *datasetA = [self.fetchedResultsController objectAtIndexPath:indexPath];
}
Run Code Online (Sandbox Code Playgroud)
但我正在尝试加载错误的数据集单元格.
这应该工作,我需要看看错误在哪里?或者我这部分做错了吗?
编辑:
我有什么应该工作.问题是索引没有排队.
对于我的fetchedResultsController,我将其创建为:
_fetchedResultsController = [Dataset MR_fetchAllSortedBy:NAME
ascending:TRUE
withPredicate:predicate
groupBy:@"datasetType"
delegate:self.fetchedResultsController.delegate
inContext:[NSManagedObjectContext MR_contextForCurrentThread]];
Run Code Online (Sandbox Code Playgroud)
这将获取它们并按名称对它们进行排序.我在项目中使用Magical Record,并使用其fetch控制器,因为我无法使Core Data fetch控制器工作:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Dataset" inManagedObjectContext:[NSManagedObjectContext MR_contextForCurrentThread]];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:NAME ascending:TRUE selector:@selector(caseInsensitiveCompare:)];
NSArray *sortDescriptors = [NSArray …Run Code Online (Sandbox Code Playgroud) objective-c nsfetchedresultscontroller ios magicalrecord uicollectionview
我有一个MKMapView.我添加了UITapGestureRecognizer一个单击.
我现在想MKAnnotationView在地图上添加一个.我可以点击注释并mapView:mapView didSelectAnnotationView:view触发(这是我将添加额外逻辑以显示UIView的地方).
问题是,当我点击注释时,MKMapView点击手势也会触发.
我可以设置它,如果我点击注释,它只响应?
我理解在NSDictionary中使用常量作为你的名字以防止拼写错误(myName将自动完成vs @"myName"不会).
我正在使用中等大小的词典,现在和几次,我错误地输入了关键名称,并且不得不花一些时间追踪我想念拼写单词的地方.
我想知道,你认为设置常量命名方案是否值得?
数组的快速枚举是否总是按索引顺序排列?
for (NSDictionary *zone in myArray)
{
//do code
}
Run Code Online (Sandbox Code Playgroud)
总是从索引位置0,1,2,...,n枚举?
我更喜欢快速枚举而不是标准for循环,因为它使代码更容易阅读.
我需要做一系列的url调用(获取WMS tile).我想使用LIFO堆栈,因此最新的url调用是最重要的.我想现在在屏幕上显示瓷砖,而不是5秒前在屏幕上显示在屏幕上的瓷砖.
我可以从NSMutableArray创建自己的堆栈,但我想知道NSOperationQueue是否可以用作LIFO堆栈?
我正在为iPad应用程序创建一个程序按钮.当我看到按钮时,它下面看起来像是一个阴影类型的东西.它是什么,我怎么能摆脱它?
这是创建它的代码:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.titleLabel.font = [UIFont fontWithName:@"Trebuchet MS" size:12];
[myButton setTitle:@"test" forState:UIControlStateNormal];
myButton.frame = CGRectMake(0, 0, self.leftScrollView.frame.size.width, 50);
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gear12.png"]];
[myButton addSubview:myImageView];
[self.leftScrollView addSubview:myButton];
Run Code Online (Sandbox Code Playgroud)
更新:
好的,我注意到我只在滚动视图中得到了这个效果.如果我将它添加到视图中,没有阴影效果.
顶部测试按钮,按钮是视图的子视图.底部按钮是滚动视图的子视图,滚动视图是视图的子视图(按钮/视图与按钮/滚动视图/视图).
白色部分是视图,灰色是滚动视图/视图.

更新2:
正如robmayor所指出的那样,UIButtons总是具有双线效果,当背景颜色为白色时不会引起注意.蓝色是视图,灰色是子视图scrollview.

有没有办法模糊/淡出UIView的边界?
到目前为止,我对核心图形做了很少甚至没有做过.
希望表格视图在纵向时从顶部向下显示300像素,在横向时从顶部向下显示约175像素.
我似乎无法弄清楚我需要的VFL逻辑.
UIView是否创造了intrinsicContentSize?
我创建了一个UIView contentView.我不给它约束大小:
UIView *contentView = [UIView new];
[contentView setTranslatesAutoresizingMaskIntoConstraints:NO];
contentView.backgroundColor = [UIColor orangeColor];
Run Code Online (Sandbox Code Playgroud)
我创建了另一个UIView subview01.我给它约束大小并将其添加到我的contentView:
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[imageView setTranslatesAutoresizingMaskIntoConstraints:NO];
imageView.userInteractionEnabled = TRUE;
imageView.backgroundColor = [UIColor clearColor];
[imageView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[imageView(WIDTH)]"
options:0
metrics:@{@"WIDTH" : [NSNumber numberWithFloat:imageSize.width]}
views:NSDictionaryOfVariableBindings(imageView)]];
[imageView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[imageView(HEIGHT)]"
options:0
metrics:@{@"HEIGHT" : [NSNumber numberWithFloat:imageSize.height]}
views:NSDictionaryOfVariableBindings(imageView)]];
[contentView addSubview:imageView];
Run Code Online (Sandbox Code Playgroud)
contentView确实没有任何大小.我想intrinsicContentSize是假设要计算显示所有子视图所需的大小并自行调整大小?就像UILabel如何调整大小以显示其所有文本一样?
objective-c ×10
ios ×9
iphone ×2
autolayout ×1
mkannotation ×1
mkmapview ×1
nsdata ×1
nsdictionary ×1