Tag: uiviewcontroller

ios 7 UiView框架问题

我在iOS6和iOS7中运行的是具有NavigationBar的应用程序,它在iOS6上运行良好,但是在iOS7中,所有视图都是一点点,因为它根本没有考虑导航栏。 我曾尝试更改模拟指标选项中的topbar属性,但它不起作用。 它考虑iOS6中NavigationBar的button位置,但在iOS7中,它从屏幕顶部考虑它。 这是什么原因? 提前致谢。

UIViewController的偏好状态栏隐藏不工作

我试图让我的视图控制器之一的状态栏被隐藏(当模态显示)。 当我呈现视图控制器时,状态栏将被隐藏,然后被解散时返回。 我已经将下面的代码添加到呈现的视图控制器 – (BOOL)prefersStatusBarHidden { return YES; } 我还将Info.plist文件中的密钥设置为以下内容: <key>UIViewControllerBasedStatusBarAppearance</key> <true/> 根据我的理解,这应该是完成这项工作所需的一切。 我也使用自定义animation控制器来执行符合UIViewControllerAnimatedTransitioning协议的呈现。 在animateTransition:实现中,我试图手动调用prefersStatusBarHidden ,后面跟着setNeedsStatusBarAppearanceUpdate以确保调用正在进行,但状态栏仍然存在。 任何想法,为什么发生这将不胜感激。 我已经searchStackOverflow,但似乎没有人有这个问题,所有接受的答案指的是调用setNeedsStatusBarAppearanceUpdate ,我已经在做。 编辑 – 下面的代码现在似乎工作正常 – (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext { if (self.isPresenting) { UIView *containerView = [transitionContext containerView]; UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; toViewController.view.frame = containerView.frame; [containerView addSubview:toViewController.view]; // Ask the presented controller whether […]

“UIViewController子类”不出现在xcode 4.3的文件模板库中

目前我对XCODE开发相当陌生,下面有几个教程。 碰到一个意想不到的问题 – 寻求帮助! 问题是“UIViewController子类”没有出现在文件模板库中。 我的书和每一页我检查了这个模板下的iOS或Mac“cocoa触摸”类别。 我的xcode只显示“Objective-C类”“Objective-C类”“Objective-C类扩展”“Objective-C协议”“Objective-Ctesting用例类” 我如何添加UIViewController子类的新文件模板? 我的环境: – 雪豹 – xcode版本:4.3 提前致谢!

从Storyboard实例化View Controller与创build新实例

从故事板实例化视图控制器和创build它的新实例之间的function区别是什么? 例如: #import "SomeViewController.h" … SomeViewController *someViewController = [SomeViewController new]; 与 #import "SomeViewController.h" … UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; SomeViewController *someViewController = [storyboard instantiateViewControllerWithIdentifier:@"SomeViewController"]; 在任何情况下, someViewController有效地是相同的东西?

UIViewController初始化和加载顺序

我对Mac和iPhone上的UI编程相当陌生,而且碰到了让我感到困惑的东西。 一个UIViewController有3个涉及它的初始化和它的视图的方法: init(和类似init的方法) 的loadView viewDidLoad(委托方法) 我希望这些发生在上面的顺序。 首先UIViewController由其他对象分配,然后立即调用init(或其他一些init方法,如initWithStyle)。 只有对象被初始化后,我希望它调用自己的loadView函数,之后,视图,一旦加载,调用viewDidLoad委托方法。 这不会发生,例如: @implementation UIViewControllerSubclass – (id)init { NSLog(@"0"); if (self = [super init]) { NSLog(@"1"); } return self; } – (void)loadView { [super loadView]; NSLog(@"2"); } – (void)viewDidLoad { [super viewDidLoad]; NSLog(@"3"); } @end 生成控制台输出: 0 2 3 1 因此,loadView和viewDidLoad方法不能进行委托调用,因为通常在调用[super init]之后设置委托, 在 loadView和viewDidLoad运行之后调用该方法(如上所示): UIViewControllerSubClass *someViewController = [[UIViewControllerSubclass alloc] […]

如何强制UIView的layoutSubviews。

我有一个自定义的UIView有一个专门的,手动设置框架纵向和横向,因为autoresizingMasks只是不工作在我的情况。 我把这个框架设置在: – (void)viewWillAppear:(BOOL)animated 它按预期工作。 现在我的问题是,我的UIView还有子视图,也有专门的肖像/风景的位置。 我将这些子视图定位在: – (void)layoutSubviews 如果我现在离开我的viewController在纵向方向,旋转到另一个viewController横向,然后回到这个viewController我看到我的看法得到正确的resize,但我的视图,在layoutSubviews定位的子视图尚未重新定位,但在已经出现的观点之后,以animation的方式resize。 我什么都不做,我已经试过打电话了 – (void)layoutIfNeeded 以及: – (void)setNeedsLayout 有鉴于此,似乎并没有改变什么。 任何想法我做错了什么? 谢谢。

在iOS5中使用UISegmentedControl切换ViewController

我正在尝试一些非常简单的东西,但不知何故我无法得到它的工作。 我所要做的就是使用UISegmentedControl在2个视图控制器之间进行切换,例如您可以在Highlights选项卡的App Store应用程序中看到它。 我正在使用iOS5和故事板。 这是我的Storyboad排队: 所以我有一个根视图控制器和两个UITableViews – 这2个TableViews我想切换。 这是实现文件的样子 #import "SegmentedLocationViewController.h" #import "PastEventsLocationViewController.h" #import "FutureEventsLocationViewController.h" @interface SegmentedLocationViewController() @property (weak, nonatomic) IBOutlet UISegmentedControl *segmentedControl; @property (strong, nonatomic) NSArray *viewControllers; @end @implementation SegmentedLocationViewController @synthesize segmentedControl = _segmentedControl; @synthesize viewControllers = _viewControllers; – (IBAction)indexDidChangeForSegmentedControl:(UISegmentedControl*)segmentedControl { NSLog(@"index: %d", segmentedControl.selectedSegmentIndex); } – (void)setupViewControllers { PastEventsLocationViewController *pastEventsLocationViewController = [[PastEventsLocationViewController alloc] initWithStyle:UITableViewStylePlain]; […]

将工具栏添加到UITableViewController

将UIToolBar添加到UITableViewController最简单的方法是什么? 我依赖于编辑function,所以我不能轻松地将UITableViewController更改为UIViewController。

添加UIGestureRecognizer从左到右从右到左滑动我的意见

我有一个UIStoryboard与不同的UIViewControllers ,我想添加另一个UIViewController (如仪表板),当用户从左侧滑动iPad的仪表板将出现,然后当他向后滑动当前视图将被恢复。 这可能吗? 如果是的话提示如何做或UIGestureRecognizer任何好的教程? 谢谢。

如何做两个UIViewControllers之间的翻转animation,同时点击信息button?

我有一个名为“LoginViewController”的login页面。 我在这个页面有一个信息button。 如果我点击它,我想显示一些关于我的应用程序的信息。 我也想用翻页animation来呈现那个信息页面。 创build信息button的代码是, infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; infoButton.frame = CGRectMake(285, 425, 30, 30); infoButton.backgroundColor = [UIColor clearColor]; [infoButton addTarget:self action:@selector(displayInfoView) forControlEvents:UIControlEventTouchUpInside]; 如果我点击信息button, displayInfoView方法将被调用。 在那里我可以显示一个UIView来显示一些信息。 我对吗? 对于翻转animation,我使用这个代码… [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:.8]; [UIView setAnimationTransition:([loginPageView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:mainView cache:YES]; if ([infoView superview]) { [infoView removeFromSuperview]; [mainView addSubview:loginPageView]; } else { [loginPageView removeFromSuperview]; […]