在加载集合视图之前,用户设置集合视图数组中的图像数.所有细胞都不适合屏幕.我有30个单元格,屏幕上只有6个单元格.
问题:如何在UICollectionView的加载下自动滚动到具有所需图像的单元格?
我正在尝试在我的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) 我想在目标C中以编程方式在我的应用程序Documents文件夹中创建plist文件.我在文档目录中创建一个文件夹:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/Data.plist", documentsDirectoryPath];
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个看起来像XML文件的plist文件./****必需的XML文件****/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>height</key>
<integer>4007</integer>
<key>name</key>
<string>map</string>
<key>width</key>
<integer>6008</integer>
</dict>
</array>
</plist>
Run Code Online (Sandbox Code Playgroud)
/****通过代码****/获得文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>height</key>
<string>4007</string>
<key>name</key>
<string>map</string>
<key>width</key>
<string>6008</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
所需文件需要一个数组,在数组中我们有一个字典对象.我怎么能改变这个?我也知道如何将文件写入路径,但主要问题是如何创建plist文件然后读取它?
我有一个横向UIScrollView分页.有两个按钮.一个向左滚动scrollView到另一个向右.
左边的代码:
- (IBAction)goLeftAction:(id)sender
{
CGFloat pageWidth = _theScrollView.frame.size.width;
int page = floor((_theScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
if(page>0){
page -=1;
[_theScrollView scrollRectToVisible:CGRectMake(_theScrollView.frame.size.width*page, 0, self.view.frame.size.width, self.view.frame.size.height) animated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
scrollView当我们在第一页(页面= 0)并按下左键时,我希望按钮使显示弹跳效果.
请帮助找到实现这一目标的方法.
编辑:
如果有人需要,这是代码.
首先我加入了 goLeftAction:
[_theScrollView setPagingEnabled:NO];
[_theScrollView setScrollEnabled:NO];
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(bounceScrollView) userInfo:nil repeats:NO];
Run Code Online (Sandbox Code Playgroud)
接下来:
- (void)bounceScrollView
{
[self.theScrollView scrollRectToVisible:CGRectMake(100, 0, self.view.frame.size.width, self.view.frame.size.height) animated:YES];
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unbounceScrollView) userInfo:nil repeats:NO];
}
- (void)unbounceScrollView
{
[self.theScrollView scrollRectToVisible:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) animated:YES]; …Run Code Online (Sandbox Code Playgroud) ios ×4
bounce ×1
cocoa-touch ×1
iphone ×1
nspredicate ×1
objective-c ×1
plist ×1
uibutton ×1
uiscrollview ×1