在我的应用程序中,我有多个视图,一些视图需要支持纵向和横向,而其他视图只需要支持纵向.因此,在项目摘要中,我已经选择了所有方向.
以下代码用于在iOS 6之前禁用给定视图控制器上的横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)
由于在iOS6中不推荐使用shouldAutorotateToInterfaceOrientation,我将以上内容替换为:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
Run Code Online (Sandbox Code Playgroud)
当视图出现时我会正确调用此方法(我可以设置断点以确保这一点),但是界面仍然会旋转到横向模式,而不管我是否仅为纵向模式返回蒙版.我究竟做错了什么?
似乎目前无法构建一个每个视图具有不同方向要求的应用程序.它似乎只遵循项目摘要中指定的方向.
我在iOS 5中收到此错误
-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance 0xa217200
但是,我在iOS 6中没有错误.我该如何解决这个问题?这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; /// SIGABRT error
if (!cell)
{
cell = [[UITableViewCell alloc]
initWithStyle: UITableViewCellStyleSubtitle
reuseIdentifier: CellIdentifier];
}
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我一直在网上寻找解决方案,但一无所获.我正在尝试使我的iOS 5应用iOS 6兼容.我无法让定位的东西正常工作.我无法检测到旋转何时发生.这是我正在尝试的代码:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)
新的supportedInterfaceOrientation:方法被调用就好了.但是,shouldAutorotate方法不会触发.我需要在旋转时进行一些图像交换,但我无法得到旋转即将发生的任何迹象.
提前致谢.
我正在努力实现以下目标:
我阅读了一个关于这样做的教程并且它可以工作,但问题是它需要两个视图具有相同的宽度和引脚Widths equally,这是我不想要的.
这是我试过的:
我遇到的问题是左视图没有调整大小,右视图填充空间以保持20像素的水平空间.
有没有办法让两个视图按比例调整它们应该填充的空间?
以下是我的布局和约束的屏幕截图:


谢谢!
编辑
我尝试旋转设备时收到以下警告:
2012-10-11 08:59:00.435 AutolayoutTest[35672:c07] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this: (1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it. (Note:
If you're seeing NSAutoresizingMaskLayoutConstraints …Run Code Online (Sandbox Code Playgroud) 我正在编写一个应用程序,它在大部分屏幕上显示一个简单的Apple Map.但是,当我比较滚动速度时,与iOS 6附带的原生Apple Maps相比,显着减慢了速度.
在我调查原因时,我注意到Facebook App(也使用Apple Maps),同样的性能打击存在.
这在使用iOS 6的iPhone 4上最为明显.
有谁知道我需要采取的与视图相关的特殊性能增强步骤或一组步骤来提高性能?我希望我的地图像Apple Maps应用程序一样流畅.
我有一个使用地址簿的应用程序.在iOS 6中运行时,当用户执行需要通讯簿访问的操作时,它会运行此代码.
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
{
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error)
{
if (granted)
{
showContactChooser();
}
});
CFRelease(addressBookRef);
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized)
{
showContactChooser();
}
else
{
showAccessDeniedAlert();
}
Run Code Online (Sandbox Code Playgroud)
这非常有效:我能够阅读联系人信息,当用户拒绝访问时,应用程序会做出相应的反应.
但是,如果用户:
应用程序立即崩溃main(),没有异常信息或有意义的堆栈跟踪.我尝试打开"所有异常"和[NSException raise]断点,但这并没有给我任何更多信息.
即使应用程序在启动期间未运行上述代码,也可以重现崩溃.
这里发生了什么事?我应该订阅回调吗?
我的应用程序支持iOS 6.1.如何在Xcode 6中找到并安装该模拟器?
我的UIPageViewController在iOS 5中运行良好.但是当iOS 6出现时,我想使用新的滚动转换样式(UIPageViewControllerTransitionStyleScroll)而不是页面卷曲样式.这导致我的UIPageViewController破坏.
在我打电话之后,它工作得很好setViewControllers:direction:animated:completion:.之后,下次用户手动滚动一页时,我们会得到错误的页面.这有什么不对?
有没有办法让一个ContainerView具有多个嵌入段?目的是让ContainerView根据按下的按钮保持几个不同的ViewControllers; 一次只能看到一个.我想使用嵌入segues,这样在Interface Builder中,故事板会自动显示与ContainerView相同的大小.
我意识到我可以手动调整InterfaceBuilder中的其他ViewControllers,但我想要嵌入segue提供的自动调整大小.如果可以采用另一种方式,那也没关系.没有在viewDidLoad上加载视图很好 - 如前所述,显示的ViewController可以根据按下的按钮进行更改.
我刚刚通过ios 6将facebook集成到我的应用程序中,但是在我的墙上发布时遇到了问题.它只是说"通过ios app发布".我希望它说"通过应用名称发布".我已经与Facebook建立了应用程序标识,我有他们分配的应用程序编号,但我不确定如何将其与facebook集成集成.
以下是我的代码.如果有人可以提供帮助,我们将不胜感激.谢谢!
{
NSString *message;
message= [[NSString alloc] initWithFormat:@"I've earned %@ points", [self retrieveScore]];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:message];
[controller addURL:[NSURL URLWithString:@"http://mysite"]];
[self presentViewController:controller animated:YES completion:Nil];
[message release];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
NSString *output= nil;
switch (result) {
case SLComposeViewControllerResultCancelled:
output= @"Action Cancelled";
NSLog (@"cancelled");
break;
case SLComposeViewControllerResultDone:
output= @"Post Succesfull";
NSLog (@"success");
break;
default:
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert …Run Code Online (Sandbox Code Playgroud) ios6 ×10
ios ×9
objective-c ×4
cocoa-touch ×2
iphone ×2
xcode ×2
autolayout ×1
facebook ×1
ios5 ×1
mapkit ×1
performance ×1
rotation ×1
segue ×1
uitableview ×1
xcode6 ×1