我刚刚开始使用Storyboard和iOS 5.1.我正在构建的应用程序使用导航控制器作为其根控制器,旨在用于横向(它是一个内部企业应用程序).
我创建了一个正常工作的单个视图:当模拟器改变方向时,内容正确旋转以保持"正面朝上".
然后我添加了一个新视图,那个视图根本不旋转; 当设备旋转时,内容保持纵向(因此是侧面).
我查看了两个UIViewControllers和UIViews的设置,看不出它们之间有什么区别.关于我应该在哪里看的任何想法?
我正在尝试创建自定义segue,以便目标视图控制器从顶部向下滑动.
我根据文档中的示例编写了我的代码.
问题是当执行segue时,源视图控制器变黑,然后动画发生.如何防止源视图控制器变黑?
(我已经尝试实现此答案中提供的解决方案,但屏幕在转换后变为黑色,或者恢复为源视图控制器.)
这是我的代码:
-(void)perform{
UIViewController *splashScreen = self.sourceViewController;
UIViewController *mainScreen = self.destinationViewController;
//Place the destination VC above the visible area
mainScreen.view.center = CGPointMake(mainScreen.view.center.x,
mainScreen.view.center.y-600);
//Animation to move the VC down into the visible area
[UIView animateWithDuration:1
animations:^{
mainScreen.view.center = CGPointMake(mainScreen.view.center.x, [[UIScreen mainScreen] bounds].size.height/2 );
}
];
[splashScreen presentModalViewController:mainScreen animated:NO];
}
Run Code Online (Sandbox Code Playgroud) 我希望有一个从右向左滚动的UICollectionView,即当它在加载后出现在屏幕上时,收集视图应该首先显示最右边的单元格/项目,然后在左边添加其余的.我已经尝试了这里提供的解决方法,但是如果我打电话给viewWillAppear:我,我得到:
*** Assertion failure in -[UICollectionViewData layoutAttributesForItemAtIndexPath:], /SourceCache/UIKit/UIKit-2372/UICollectionViewData.m:485
Run Code Online (Sandbox Code Playgroud)
如果我滚动到它中的最后一项viewDidAppear:工作正常,除了现在用户首先看到左项,然后滚动到最后一项.使用也试过contentOffset在UICollectionView财产(因为它的UIScrollView的一个子类),但这个参数也只设置在某个时候之间viewWillAppear:和viewDidAppear:
任何替代品?我想我可以尝试子类化UICollectionViewFlowLayout并从右到左布局单元格,但我有点急于进入那个领域.
这就是我做的:
- (void)_scrollToTheRight
{
NSIndexPath *lastIndexPath = [self.fetchedResultsController indexPathForObject:self.fetchedResultsController.fetchedObjects.lastObject];
if (lastIndexPath)
{
[self.collectionView scrollToItemAtIndexPath:lastIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:NO];
}
}
Run Code Online (Sandbox Code Playgroud)
每个值是:
lastIndexPath
(NSIndexPath *) $0 = 0x1f1754a0 <NSIndexPath 0x1f1754a0> 2 indexes [0, 21]
(NSInteger)[self.fetchedResultsController.fetchedObjects count]
(NSInteger) $3 = 22 [no Objective-C description available]
(NSInteger)[self.collectionView numberOfItemsInSection:0]
(NSInteger) $2 = 22 [no Objective-C description available]
Run Code Online (Sandbox Code Playgroud)
最后一点:集合视图控制器是从UIPageViewController放在屏幕上的视图控制器的容器视图(iOS 6故事板中的新内容)加载的.
谢谢.
编辑1:
所以我认为问题是使用我的故事板布局(UICollectionViewController …
我创建了一个切片UITableView并添加了一个自定义单元格,其中包含一个UISwitch.所有这些都是使用故事板完成的.但是,在运行App(模拟器/设备)时,UISwitch看起来并不像预期的那样(参见附件截图).关于为什么会发生这种情况的任何想法都受到高度赞赏(XCode 4.5.2,iOS 6.0.1).注意:创建新的UIStoryboard并不能解决问题.

我有一个视图控制器布局在故事板中启用自动布局,我正在寻找一种方法来更改约束,以允许我的视图旋转到横向和重新排列屏幕上的按钮.当我尝试下面的代码时,我得到了大约二十几个"无法满足约束,打破约束......"消息,我无法真正解码.
有没有办法用编程方式指定的约束动态替换故事板中的约束?我想完全覆盖我在故事板中定义的按钮的布局.
-(void)updateViewConstraints
{
[super updateViewConstraints];
self.loginButton.translatesAutoresizingMaskIntoConstraints = NO;
self.getStartedButton.translatesAutoresizingMaskIntoConstraints = NO;
self.takeTourButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.loginButton removeConstraints:self.loginButton.constraints];
[self.getStartedButton removeConstraints:self.getStartedButton.constraints];
[self.takeTourButton removeConstraints:self.takeTourButton.constraints];
one = self.loginButton;
two = self.getStartedButton;
three = self.takeTourButton;
NSDictionary *metrics = @{@"height":@50.0,@"width":@100.0,@"leftSpacing":@110.0};
NSDictionary *views = NSDictionaryOfVariableBindings(one,two,three);
[self.view removeConstraints:activeTestLabelConstraints];
[activeTestLabelConstraints removeAllObjects];
if(isRotatingToLandscape)
{
[self registerConstraintsWithVisualFormat:@"|-[one(two)]-[two(three)]-[three]-|" options:NSLayoutFormatAlignAllTop | NSLayoutFormatAlignAllBottom metrics:metrics views:views];
[self registerConstraintsWithVisualFormat:@"V:[one(height)]-|" options:0 metrics:metrics views:views];
}else
{
[self registerConstraintsWithVisualFormat:@"|-leftSpacing-[one(width)]" options:0 metrics:metrics views:views];
[self registerConstraintsWithVisualFormat:@"[two(width)]" options:0 metrics:metrics views:views];
[self registerConstraintsWithVisualFormat:@"[three(width)]" options:0 metrics:metrics views:views];
[self registerConstraintsWithVisualFormat:@"V:[one(height)]-[two(75)]-[three(100)]-|" options:NSLayoutFormatAlignAllCenterX metrics:metrics views:views];
} …Run Code Online (Sandbox Code Playgroud) 正如问题已经说明的那样:当我将原型UITableViewCell添加到我的TableView时,单元格不会显示在顶部,这里是一个图像:

如何才能将单元格重新置于TableView的顶部?
我有一个故事板和一个带容器视图的视图控制器.在故事板中,我使用"嵌入"segue定义了从容器到另一个视图控制器的连接.如何从父视图控制器中获取对嵌入式视图控制器的引用?
我已经创建了对容器的引用,但是看到它只是一个UIView
这是我正在使用的segue


我想让标签出现在图像视图上.但当我将标签贴在上面时,它会消失.什么是最好的方式?
我的图像视图中有几个标签.当我构建并运行它时,标签看起来很好.但是在故事板上,当我将ui项目(如标签)放在我的图像视图上时,它没有显示.我怎么能做这个节目
正如在屏幕截图中看到的,我看不到我的标签它在我构建和运行时出现但在故事板上图像视图隐藏它仍然是一个问题.
我可以看到将图像平铺/重复到UIView或UIImage上的所有方法都包含一些Swift代码,但是我无法在启动屏幕上使用Swift.如何使用我需要在整个UIView上水平和垂直重复的图案图像?
uistoryboard ×10
ios ×8
objective-c ×4
swift ×2
autolayout ×1
embed ×1
ios6 ×1
storyboard ×1
uiimageview ×1
uiscrollview ×1
uiswitch ×1
uitableview ×1
uiview ×1
xcode ×1