在Swift中,我注意到没有@autoreleasepool{}
构造,尽管Swift确实使用ARC.在Swift中管理autoreleasepool的正确方法是什么,或者由于某种原因将其删除了?
我的目标是在启动应用程序时从类似于跳板图标的视图为用户提供缩放模式转换.
呈现的视图控制器正确放大,但导航栏在状态栏下位置错误.调用[transitionContext completeTransition:finished];后,该位置得到纠正.如何从过渡开始就做到正确?
这是一个错误的屏幕录制:http://youtu.be/7LKU4lzb-uw(小故障在录音的第6秒)
UIViewControllerAnimatedTransitioning代码:
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIView *container = [transitionContext containerView];
CGPoint viewCenter = self.view.center;
CGSize viewSize = self.view.frame.size;
CGSize controllerSize = toViewController.view.frame.size;
CGFloat controllerFromX = viewCenter.x - (controllerSize.width / 2);
CGFloat controllerFromY = viewCenter.y - (controllerSize.height / 2);
CGAffineTransform transform = CGAffineTransformMakeTranslation(controllerFromX, controllerFromY);
transform = CGAffineTransformScale(transform, viewSize.width / controllerSize.width, viewSize.height / controllerSize.height);
if (self.reverse) {
[container insertSubview:toViewController.view belowSubview:fromViewController.view];
} else {
toViewController.view.transform = transform;
[container …
Run Code Online (Sandbox Code Playgroud) 当用户滚动到底部时,我正在尝试自动获取并加载下一页单元格UICollectionView
.
我可以通过添加一个这样做UIButton
的UICollectoinView
页脚.当用户滚动到页脚并触摸按钮时,会正确添加新单元格.UIButton
在页脚中可以再次触摸以添加更多页面.
我试图自动化它,所以当用户滚动到底部时,自动调用添加新单元格的正确方法:
- (UICollectionReuseableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind: (NSString *)kind atIndexPath: (NSIndexPath *) indexPath
{
// code for headerView
// ...
// code for footerView
MySupplementalFooter *footerView = nil;
if ( [kind isEqual:UICollectionElementKindSectionFooter] )
{
footerView = [self.collectionView dequeueReuseableSupplemntaryViewOfKind:kind withReuseIdentifier:@"FooterId" forIndexPath:indexPath];
if (LoadMoreIsEnabled)
{
footerView.loadMoreFooterButton.setHidden:NO];
[self loadMoreFooterButtonAction]; // calls the method to add cells to the dictionary for cv
} else
{
footerView.loadMoreFooterButton setHidden:YES];
}
return footerView;
}
}
Run Code Online (Sandbox Code Playgroud)
loadMoreFooterButtonAction
调用该方法,但整个 …
当我收到崩溃报告时,我的代码中有问题的部分有时看起来像这样,而不是向我显示实际的行号,即使崩溃报告是象征性的:
-[ViewController myMethod:] + 47
Run Code Online (Sandbox Code Playgroud)
为了调试这个,我需要知道我代码的代码行,以便我可以直观地检查它,设置断点等.
如上所示,使用LLDB获取方法地址加偏移的好方法是什么?
注意:此问题与如何阅读崩溃报告不重复.我知道如何阅读崩溃报告.我非常具体地询问如何使用LLDB获取相应的行.其他答案中没有任何内容显示如何做到这一点.它们非常冗长,并且涉及一般处理崩溃报告和调试的各种事情,但没有说明LLDB的具体步骤是什么.请不要复制此错误.
Apple技术说明QA1037说"要创建一个仅限alpha的位图上下文,只需为colorspace参数传递NULL."
但是,我不确定要为bitmapInfo
参数传递什么.
我正在尝试这样的事情,使用kCGImageAlphaOnly:
CGContextRef ctx = CGBitmapContextCreate(NULL, scaledSize.width, scaledSize.height, 8, scaledSize.width, NULL, kCGImageAlphaOnly);
Run Code Online (Sandbox Code Playgroud)
但这给了我一个关于枚举错误的警告.我应该把它放在那里呢?
我的应用程序由全屏幕驱动UIWebView
.它运行良好,除非键盘启动时视图移动大约10个像素,留下白色间隙(见下面的屏幕截图).
有谁知道是什么原因造成这种情况,是否有任何解决方案或解决方法?
更新:更具体地说,UIWebView
不会转移,HTML内容正在转移.
设置:我有一个UICollectionView
或UITableView
那个由简单的数组数据源支持.我在控制器中保留了该数据源的副本.
现在,我从系统收到一条通知,告知有新数据可用.我得到一个新的数组,其中可能已添加,删除和更改位置的项目.
所以现在我有两个数据对象:
为了使UI与新数组同步,我需要生成一堆UI调用.如果是UICollectionView
,那些是
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
- (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths
Run Code Online (Sandbox Code Playgroud)
还有一套类似的方法UITableView
.
我特别不想重新加载整个表,因为这比仅使用几个项目更昂贵.
因此,问题是:给定前一个和新的数据源数组,如何生成正确的UI调用集,以及何时"换出"旧的数据源为新的?
有时我宣布一个伊娃,但过了一段时间我不再使用它了.我想从我的代码中删除这种瑕疵,但我找不到警告,告诉我我未使用过的ivars.
是否有Xcode的工具或内置功能可以让我找到所有未使用过的ivars?
我看到静态分析器有CLANG_ANALYZER_OBJC_UNUSED_IVARS,但似乎没有做任何事情.
@implementation AppDelegate
{
@private
BOOL _foo; // Never read or written to
}
Run Code Online (Sandbox Code Playgroud)
使用设置为YES的CLANG_ANALYZER_OBJC_UNUSED_IVARS(未使用的ivars)在Xcode 5中运行分析器从不产生警告.
我想暂停,UIImageView animation
并根据我的研究发现,你可以停止图像的动画,但你不能暂停序列.通过调用语句stop animating
上UIImageView
,然后它停止动画,显示空白图像视图.
要暂停UIImages的动画,必须使用NSTimer
.
我已经NSTimer
在应用程序中使用一个view controllers
以不同的时间间隔一个接一个地加载.我UIImages
每个都有幻灯片view controller
.
问题是当暂停计时器暂停view controllers
进一步加载但当时view controller
显示的那个仍然重复显示幻灯片UIImages
,view controller
直到恢复暂停.所以我想暂停那个幻灯片.
这是我使用的地方 NSTimer
-(void)playpauseAction:(id)sender {
if([audioPlayer isPlaying])
{
[sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
[audioPlayer pause];
[self pauseTimer];
}else{
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
[self resumeTimer];
if(isFirstTime == YES)
{
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
isFirstTime = NO;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这就是displayviewsAction以不同的时间间隔一个接一个地加载11个视图控制器的方式
- …
Run Code Online (Sandbox Code Playgroud) 我有一个UIColor
传递给我的.我需要检测它是否是纯色(例如创建的colorWithRed:green:blue:alpha:
)或者是否是用它创建的颜色colorWithPatternImage
.
我怎么知道颜色UIColor
是什么,颜色简单还是其他?
我最初使用FBLoginView在最新的Facebook SDK(3.5)中启动登录过程.但是,由于某种循环,这会使应用程序崩溃.然后我读到我应该尝试使用下面的代码作为测试登录:
[FBSession openActiveSessionWithReadPermissions:[NSArray arrayWithObjects:@"read_stream", nil] allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// session might now be open.
NSLog(@"Error - %@", error);
}];
Run Code Online (Sandbox Code Playgroud)
我有完全相同的问题.调用大量进程(具有相同名称)并且应用程序崩溃.有谁知道为什么在使用Facebook SDK时会发生这种情况?这是崩溃的线程的图像:
正如你所看到的,这里有些东西不对.有人有任何想法吗?
问候,
迈克
ios ×8
iphone ×3
objective-c ×3
xcode ×2
alpha ×1
cocoa-touch ×1
facebook ×1
ios7 ×1
ivar ×1
lldb ×1
swift ×1
uicolor ×1
uiimageview ×1
uikit ×1
uitableview ×1
uiwebview ×1