我正在运行此代码......
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGAffineTransform settingsTransform = CGAffineTransformMakeTranslation(self.settingsView.frame.size.width, 0);
CGAffineTransform speedTransform = CGAffineTransformMakeTranslation(-self.speedView.frame.size.width, 0);
self.settingsView.transform = settingsTransform;
self.speedView.transform = speedTransform;
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
但是当它运行时,视图会在相反方向上跳转一半,然后在正确的方向上滑动到半个位置.
我已经将动画持续时间减慢到5秒,但是初始跳跃是瞬时的,一半的转换是错误的方向.
当我使用此代码动画回来时......
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.settingsView.transform = CGAffineTransformIdentity;
self.speedView.transform = CGAffineTransformIdentity;
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
它完全一样.
结果是最终运动是所需变换的一半,因为它首先在错误的方向上跳过一半变换.
我真的无法理解为什么会这样?
有任何想法吗.
::编辑::
清除一些可能的歧义.
我并不是试图将这些观点"反弹"回到原来的位置.我正在制作动画的视图就像屏幕边缘的控制面板.当用户按下"go"时,视图会滑出.当用户按下"停止"时,面板滑回视图.
至少他们习惯了.由于启用了自动布局(我需要应用程序的其他部分),我不能只改变视图的框架,所以我去了转换路径.
您可以通过将视图粘贴到视图控制器和运行动画的按钮来查看此效果.
谢谢
我收到了错误......
*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-2372/UICollectionView.m:2249
Run Code Online (Sandbox Code Playgroud)
尝试显示UICollectionView时.
引起它的线是......
static NSString *CellIdentifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
出列错误发生.
没有其他错误,所以我很难知道从哪里开始.
任何人都可以阐明这一点吗?
我有一个AVCaptureSession与AVCaptureVideoPreviewLayer一起运行.
我可以看到视频,所以我知道它正在工作.
但是,我想要一个集合视图,并在每个单元格中添加一个预览图层,以便每个单元格显示视频的预览.
如果我尝试将预览图层传递到单元格并将其添加为子图层,则会从其他单元格中删除该图层,因此它一次只能显示在一个单元格中.
还有另一种(更好的)方法吗?
我在viewDidLoad中添加了一个像这样的集合视图......
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 10, 10) collectionViewLayout:flowLayout];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.collectionView registerClass:[CameraCell class] forCellWithReuseIdentifier:CameraCellReuseIdentifier];
[self.collectionView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:self.collectionView];
Run Code Online (Sandbox Code Playgroud)
我有一个名为CameraCell的UICollectionViewCell子类,其中包含一个init ...
- (id)init
{
self = [super init];
if (self) {
// Add customisation here...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imageChanged:) name:@"image" object:nil];
self.contentView.backgroundColor = [UIColor yellowColor];
self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.clipsToBounds = YES;
[self.imageView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.contentView addSubview:self.imageView];
NSDictionary *views = NSDictionaryOfVariableBindings(_imageView);
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_imageView]|"
options:0
metrics:nil
views:views]];
[self.contentView …Run Code Online (Sandbox Code Playgroud) 我正在尝试用它URLComponents来组成一个URL看起来像它的东西.
但是,当我访问url组件的属性时,它是零.
例...
var urlComponents = URLComponents(string: "http://google.com")!
urlComponents.path = "auth/login"
Run Code Online (Sandbox Code Playgroud)
然后我做......
print(urlComponents)
Run Code Online (Sandbox Code Playgroud)
输出...
scheme: http host: google.com path: auth/login
- scheme : "http"
- host : "google.com"
- path : "auth/login"
Run Code Online (Sandbox Code Playgroud)
但是之后...
print(urlComponents.url)
Run Code Online (Sandbox Code Playgroud)
输出nil.
我做错了吗?如何从这一切中获取完整形成的URL?谢谢
我有一个UIViewController我从另一个视图控制器内部加载,然后将其视图添加到UIScrollView.
self.statisticsController = [self.storyboard instantiateViewControllerWithIdentifier:@"StatisticsViewController"];
self.statisticsController.match = self.match;
[self.scrollView addSubview:self.statisticsController.view];
Run Code Online (Sandbox Code Playgroud)
我已经在统计视图控制器中放置断点并且viewDidLoad正在调用但viewWillAppear不是.
是因为我没有把它推到层次结构上还是什么?
objective-c uiscrollview uiviewcontroller viewwillappear ios
在UIView你可以更改backgroundColour动画.在a上UISlideView你可以改变动画的值.
您可以将自定义属性添加到您自己的UIView子类,以便它可以动画?
如果我CGPath在我的内部,UIView那么我可以通过改变路径绘制的百分比来设置它的绘图.
我可以将该动画封装到子类中.
即我有UIView一个CGPath创建一个圆.
如果圆圈不存在则表示0%.如果圆圈已满,则表示100%.我可以通过改变路径绘制的百分比来绘制任何值.我还可以通过设置动画的百分比CGPath并重新绘制路径来为变化(在UIView子类中)设置动画.
我可以设置一些属性(即百分比),UIView以便我可以将更改粘贴到一个UIView animateWithDuration块中,它可以设置路径百分比变化的动画吗?
我希望我已经解释了我想做得好的事情.
基本上,我想做的就是...
[UIView animateWithDuration:1.0
animations:^{
myCircleView.percentage = 0.7;
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
并且圆形路径以给定百分比为动画.
几天前,Xcode不断扩展项目导航器中的所有组和子组.
我一再崩溃,所以我可以专注于我正在做的事情,然后我回去,他们都会再次扩大.
还有其他人经历过这个吗?
我折叠了一个组,移动到Xcode中的另一个选项卡,然后返回,所有组都再次展开.
当我不断跟踪我正在使用的文件时,这真的令人沮丧.
我正在研究UIButton动画,其中:
它UIButton位于屏幕的底部中央,缩小为小尺寸
_menuBtn.transform = CGAffineTransformMakeScale(0.1f, 0.1f);
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,它应该移动到屏幕的左下方,因为它会缩放或增长到原始大小.
- (void)viewDidLoad
{
[super viewDidLoad];
_menuBtn.frame = CGRectMake(160, 513, 30, 30);
_menuBtn.superview.frame = CGRectMake(160, 513, 30, 30);
_menuBtn.transform = CGAffineTransformMakeScale(0.1f, 0.1f);
NSLog(@"_menuBtn: %@ ; _menuBtn.superview: %@", _menuBtn, _menuBtn.superview);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
CGAffineTransform scaleTrans = CGAffineTransformMakeScale(1.0f, 1.0f);
CGAffineTransform lefttorightTrans = CGAffineTransformMakeTranslation(-200.0f,0.0f);
_menuBtn.transform = CGAffineTransformConcat(scaleTrans, lefttorightTrans);
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
问题
当动画开始时,按钮开始从屏幕的右下方开始移动,而不是在它应该是的底部中心.有帮助吗?
记录结果
NSLog(@"%@", _myBtn);
2013-08-14 09:22:38.913 GJCoolNavi[339:c07] <UIButton: 0x813ea30; frame = (0 0; 0 0); opaque = …Run Code Online (Sandbox Code Playgroud) 在我的应用中遇到几个表视图的问题.
当表的内容发生更改(因此tableview的内容变大)时会发生问题.
出于某种原因,UITableView的contentSize保持不变,这意味着我无法滚动查看新内容.
当特定单元格变大时(在[tableView reloadData];之后)或当我添加新单元格时(使用NSFetchedResultsController委托方法),就会发生这种情况.
我是否需要为tableView重新调整其contentSize做些什么?
编辑以显示代码,但这只是样板NSFetchedResultsController委托代码...
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
// The fetch controller is about to start sending change notifications, so prepare the table view for updates.
[self.tableView beginUpdates];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
UITableView *tableView = self.tableView;
switch(type) {
case NSFetchedResultsChangeInsert:
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeDelete:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
case NSFetchedResultsChangeUpdate:
[self configureCell:(OJFPunchListCell*)[tableView cellForRowAtIndexPath:indexPath] atIndexPath:indexPath];
break;
case NSFetchedResultsChangeMove:
[tableView deleteRowsAtIndexPaths:[NSArray
arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView insertRowsAtIndexPaths:[NSArray
arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
break; …Run Code Online (Sandbox Code Playgroud) ios ×9
iphone ×4
objective-c ×3
avfoundation ×1
nsurl ×1
swift ×1
uianimation ×1
uiscrollview ×1
uitableview ×1
uiview ×1
xcode ×1