我要手动更新contentOffset的UIScrollView过程中旋转的变化.滚动视图填充屏幕,具有灵活的宽度和灵活的高度.
我目前正在尝试更新contentOffset willRotateToInterfaceOrientation,如下所示:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[Utils logPoint:myScrollView.contentOffset tag:@"initial"];
myScrollView.contentOffset = CGPointMake(modifiedX, modifiedY);
[Utils logPoint:myScrollView.contentOffset tag:@"modified"];
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[Utils logPoint:myScrollView.contentOffset tag:@"final"];
}
Run Code Online (Sandbox Code Playgroud)
但是,最终值不是修改后的值,它似乎受到它的影响,但对我来说并不明显.
这些是我得到的一些结果:
initial: (146.000000;-266.000000)
modified: (81.000000;-108.000000)
final: (59.000000;-0.000000)
initial: (146.000000;-266.000000)
modified: (500.000000;500.000000)
final: (59.000000;500.000000)
initial: (146.000000;-266.000000)
modified: (-500.000000;-500.000000)
final: (-0.000000;-0.000000)
Run Code Online (Sandbox Code Playgroud)
如何在轮换期间更新滚动视图的contentOffset?
根据iOS参考库:
在iOS 4.0及更高版本中,可以将各个资源文件标记为仅在特定类型的设备上可用.
这是否意味着如果您要为3.X设备创建通用应用程序,特别是3.2 iPad,则不能将设备特定资源用于~ipad和~iphone后缀?
如果是这样,这是处理特定于设备的资源的正确方法吗?
UIImage* anImage;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
anImage = [UIImage imageNamed:@"MyImage-iPad.png"];
} else {
anImage = [UIImage imageNamed:@"MyImage-iPhone.png"];
}
Run Code Online (Sandbox Code Playgroud)
我应该知道的任何其他考虑因素?
如何在iOS中实现子类的kCATransitionPush使用CAAnimation?
CAAnimation *animation;
// How do you create an animation that does the same than:
// CATransition *animation = [CATransition animation];
// [animation setType:kCATransitionPush];
[self.view.layer addAnimation:animation forKey:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[self.view addSubview:change];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
我知道也可以使用UIView动画,但是如果我可以实现从头开始的转换,它将有助于我更好地理解核心动画.kCATransitionPush
我想为一个dealloc方法编写iOS单元测试,该方法(基本上)将对象作为另一个对象的委托删除.
- (void) dealloc {
someObject.delegate = nil;
}
Run Code Online (Sandbox Code Playgroud)
但是,dealloc在使用ARC时我无法直接呼叫.编写单元测试的最佳方法是什么?
当NSSavePanel应用程序处于后台显示一段时间时,我收到以下错误:
RVS:__54-[NSRemoteSavePanel _runOrderingOperationWithContext:]_block_invoke_0319 : Timeout occured while waiting for the window
Remote Window Controller requested NSRequestRetryActivateSharedwindow...
Run Code Online (Sandbox Code Playgroud)
此外,面板不会出现并runModal返回NSFileHandlingPanelCancelButton.
该应用程序是沙盒.这是创建面板的代码:
NSSavePanel *panel = [NSSavePanel savePanel];
NSInteger result = [panel runModal];
if (result == NSFileHandlingPanelOKButton)
{
// Do something
}
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?
如果应用程序位于前台,则会显示面板而不会出现任何错误.
如何NSDocument以一种格式将另一种格式导出为另NSDocument一种格式?
我想在我的基于文档的应用程序中实现典型的导出选项.我不确定我应该在哪里放置格式转换代码,以及Cocoa已经提供的内容.
我的单元测试套件包含一些仅适用于最新iOS版本的测试用例.预计,在较旧的iOS版本上运行套件时,这些测试会失败.
是否有标准方法来指示这些测试用例应仅在特定的iOS版本上运行?
我想到的一个选择:
- (void) testSomethingThatOnlyWorksOniOS7
{
const BOOL iOS7OrHigher = floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1;
if (!iOS7OrHigher) return;
// Actual test goes here
}
Run Code Online (Sandbox Code Playgroud)
或者,我可以告诉SenTestCase您动态跳过某些测试吗?
UITableView报告contentSize使用a时报告的结果大于预期UISearchBar.对于零单元,预期的内容高度将为零.相反,以下代码在运行iOS 7的iPhone 4英寸中输出612.
@implementation HPViewController {
UITableView *_tableView;
UISearchBar *_searchBar;
UISearchDisplayController *_searchController;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
_tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:_tableView];
_searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
_searchController = [[UISearchDisplayController alloc] initWithSearchBar:_searchBar contentsController:self];
_searchController.delegate = self;
_searchController.searchResultsDataSource = self;
_tableView.tableHeaderView = _searchBar;
}
- (void)viewDidLayoutSubviews
{
CGSize contentSize = _tableView.contentSize;
NSLog(@"%f", contentSize.height); // 612.000000
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 0; }
- …Run Code Online (Sandbox Code Playgroud) 以下摘录来自Apple文档,如何在iOS 7中恢复应用程序.他们说您可以存储收据并稍后查看用户已购买的内容,或者您可以刷新App Receipt.我的问题是:
1)是否有一个应用程序收据或有多个单一收据?
2)存储这些收据更有意义,而不是直接存储用户已经购买的功能
3)我如何检查从刷新中获得的收据?到目前为止,我所有试图解析它的尝试都失败了.
4)是否有任何框架具有很多功能(在iCloud上保存收据/购买的产品,使购买更容易,处理下载,处理各种连接问题等)?甚至可能支持远程服务器(和验证).
我希望有人能提供帮助!:)
刷新应用程序收据
创建收据刷新请求,设置委托,然后启动请求.该请求支持在测试期间以各种状态获取收据的可选属性,例如过期收据 - 有关详细信息,请参阅SKReceiptRefreshRequest的initWithReceiptProperties:方法的值.
request = [[SKReceiptRefreshRequest alloc] init];
request.delegate = self;
[request start];
Run Code Online (Sandbox Code Playgroud)
收据刷新后,检查并交付任何已添加的产品.
ios ×7
iphone ×4
cocoa ×2
ipad ×2
macos ×2
objective-c ×2
unit-testing ×2
caanimation ×1
catransition ×1
ios7 ×1
nsdocument ×1
nssavepanel ×1
ocunit ×1
resources ×1
rotation ×1
storekit ×1
uiscrollview ×1
uisearchbar ×1
uitableview ×1
xcode4 ×1