我在xcode 4中制作一个ios应用程序,需要制作一个UIScrollView
包含按钮和a的应用程序UIImageView
.有谁知道如何编码?
(如果可能的话,我更愿意在故事板中这样做)
谢谢
以下是正在发生的事情的截图.
绿色背景是滚动视图中的视图(即标记"内容大小"和"内容偏移").
橙色是滚动视图框架.
键盘已启动...滚动视图可以很好地滚动内容.
现在我点击文本字段,键盘开始隐藏
虽然滚动视图(橙色)似乎是正确的高度,但内容现在已经上升了约100px(绿色).
我不知道造成这种情况的原因是 - 它是一个ios bug还是什么(它也发生在我的设备上).
这是根据键盘显示/隐藏的时间调整视图大小的代码.
- (void)keyboardWillShow:(NSNotification *)notif {
[self.mainScrollView setAutoresizesSubviews:NO];
// get the scroll view frame size
CGRect frame = [self.mainScrollView frame];
frame.size.height = self.view.frame.size.height-216;
[UIView beginAnimations:@"scrollViewAnimations" context:nil];
[UIView setAnimationDuration:0.3];
[self.mainScrollView setFrame:frame];
[UIView commitAnimations];
// add tap gesture recognizer
_tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_dismissKeyboard:)];
[_tap setDelegate:self];
[self.view addGestureRecognizer:_tap];
}
- (void)keyboardWillHide:(NSNotification *)notif {
CGRect frame = [self.mainScrollView frame];
frame.size.height = self.view.frame.size.height;
[UIView beginAnimations:@"scrollViewAnimations" context:nil];
[UIView setAnimationDuration:0.3];
[self.mainScrollView setFrame:frame];
[UIView commitAnimations];
[self.view removeGestureRecognizer:_tap]; …
Run Code Online (Sandbox Code Playgroud) 我有一个集合视图,填充了以下数据:
[self.graniteImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Angel Cream", @"name",
@"angel-cream.jpg", @"image", nil]];
[self.graniteImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@"Angola Black", @"name" ,
@"angola_black1.jpg", @"image" , nil]];
Run Code Online (Sandbox Code Playgroud)
然后有一个segue到一个静态的细节视图.
我现在想要在细节视图中添加分页,这样我就可以像在iPhone照片库中那样浏览我在集合视图中包含的图像.
我猜想要么是滚动视图还是第二次收集视图,但我不知道从哪里开始,所以任何指针,示例代码或任何其他帮助你们都可以给予大力赞赏.
谢谢
以下问题:我有一个带有几个单元格的UITableView.该表还有一个标题,我在其中添加了一个UIScrollView,它应该水平滚动.
所以现在当我在屏幕上滚动时,表格将始终滚动,但不会在标题中滚动UIScrollView,即使我在标题区域中滚动水平.
因此,似乎桌子正在管理所有滚动.如何设置UITableView滚动,以便标题中的UIScrollView处理标题区域的水平滚动.
我试图设置UIScrollView的委托并尝试UIScrollViewDelegate中的函数, - (void)scrollViewDidScroll:(UIScrollView*)scrollView,但只有表调用此函数.
我希望你能帮助我.
如果在uiscrollview上有uiscrollview和多个子视图.如何知道用户触摸的位置,即特定视图或滚动视图(空白区域)
我有一个有点复杂的设置,我有一个可缩放UIImageView
的UIScrollView
.缩放以及与其相关的所有内容均可正常工作.但是由于在iOS6/7中实现了autoLayout,我似乎无法找到让约束占用的方法UITabBar
.因此,现在图像在底部被截断,如下图所示:
在哪里我希望它显示如下:
到目前为止,我一直在搞乱所有约束,甚至考虑转储AutoLayout,只是为了稍后找到布局的其他问题.
所以我想使用AutoLayout功能,但不知道如何正确使用它们.为了确保缩放部分正常工作,我现在有这样的约束设置:
(ScrollView向左,ImageView右)
希望有人可以指出我正确的方向,如何添加/修改约束,以便TabBar
尊重和UIImageView
正确显示.
我在UICollectionView中为UIScrollView设置了一个UITapGestureRecognizer.我已将其配置为正确检测点击并触发我编写的方法,但如果我尝试将选择器设置为collectionView:didSelectItemAtIndexPath:程序在点击单元格时崩溃.
知道为什么会这样吗?
这有效:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
- (void) tapped:(UIGestureRecognizer *)gesture{
//some code
}
Run Code Online (Sandbox Code Playgroud)
这不起作用:
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(collectionView:didSelectItemAtIndexPath:)];
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//some code
}
Run Code Online (Sandbox Code Playgroud) objective-c uiscrollview ios uitapgesturerecognizer uicollectionview
我有一个UITableView
滚动禁用.
在一个UITableViewCell
,我有一个UIScrollView
.
在UITableViewCell
子类中,我实现了:
-(void)layoutSubviews
{
[mainScrollView addSubview:mainContentView];
mainScrollView.contentSize = mainContentView.bounds.size;
mainScrollView.scrollEnabled = YES;
}
Run Code Online (Sandbox Code Playgroud)
调用此方法并正确设置内容大小.
但是UIScrollView
不会滚动......你可能会形成它UITableView
吗?我已经在其他应用程序中使用a UICollectionView
中完成了同样的操作UITableView
,但它运行良好.
I am working on app in which i have to make welcome screen. In that UIPageControl
i need to display different 9 subviews. Also need infinite circular scrolling in that. It means after page-9 if i slide than page-1 should appear.
I have tried so much to implement it but never got expected results.
Can anyone help me out to get the best solution for it.
Thanks.
我有一个UITableView,我用来显示数据,要求我有一个比iPhone screenWidth宽得多的单元格.
因此我创建了一个包含子类UIScrollView的子类UITableViewCell.这就是我的代码.
TableView.h
@property (strong, nonatomic) CustomCell *cell;
Run Code Online (Sandbox Code Playgroud)
TableView.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cellDictionary = [xmlMArray objectAtIndex:indexPath.row];
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell.
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.itemsDictionary = cellDictionary;
cell.currentIndex = indexPath;
cellDictionary = nil;
[cell drawCell];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
在上面的方法中,您可以看到我正在调用我创建的自定义UITableViewCell.
CustomCell.h
@property (strong, nonatomic) NSDictionary *itemsDictionary;
@property (strong, nonatomic) MyScrollView *scrollCell;
@property (strong, nonatomic) NSIndexPath *currentIndex; …
Run Code Online (Sandbox Code Playgroud) ios ×10
uiscrollview ×10
objective-c ×4
uitableview ×3
uiimageview ×2
animation ×1
ios7 ×1
iphone ×1
scroll ×1
touch ×1
uibutton ×1