草庐IT

UiviewController

全部标签

ios - Xcode 8/swift 3 : "Expression of type UIViewController? is unused" warning

我有以下函数,它之前编译得很干净,但在Xcode8中生成了警告。funcexitViewController(){navigationController?.popViewController(animated:true)}"Expressionoftype"UIViewController?"isunused".为什么会这样说,有没有办法删除它?代码按预期执行。 最佳答案 长话短说popViewController(animated:)返回UIViewController?,并且编译器发出警告,因为您没有捕获该值。解决方案是将其分

ios - 仅锁定主 UIViewController 的方向 - iOS

我想知道如何锁定主视图Controller的方向,但允许我的用户旋转到所有ViewController的横向?提前致谢! 最佳答案 对于主视图Controller:-(NSUInteger)supportedInterfaceOrientations{returnUIInterfaceOrientationMaskPortrait;}其他ViewController-(NSUInteger)supportedInterfaceOrientations{returnUIInterfaceOrientationMaskLandscape

ios - 我可以为 iOS6 和 iOS7 的同一个 UIVIewController 设置两个不同的 xib 吗?

我可以为iOS6和iOS7设置两个不同的xib吗?我无法对两个iOS的同一个xib文件进行相同的更改,也无法在代码中设置所有内容。谢谢 最佳答案 是的,您可以只使用[[UIDevicecurrentDevice]systemVersion],如该问题的已接受答案中所述:HowtocheckiOSversion?获取版本并相应地有条件地加载正确的XIB。 关于ios-我可以为iOS6和iOS7的同一个UIVIewController设置两个不同的xib吗?,我们在StackOverflow

iphone - 如何在 iOS 5 的 segue 之间设置 Storyboard UIViewController 的属性?

当在第一个View上触摸按钮时,我试图在UIImageView上设置一个简单的图像:-(void)prepareForSegue:(UIStoryboardSegue*)seguesender:(id)sender{ImageViewController*imageViewController=[seguedestinationViewController];imageViewController.title=@"test";imageViewController.imvBig.image=[UIImageimageNamed:@"test.png"];imageViewControl

ios - 如何将第一个 UIViewController 的 View 设置为自动调整大小?

我有一个UIViewController子类来处理我的横向应用程序View。我希望它的View能够自动调整大小以反射(reflect)横向尺寸,但它似乎没有。但是,subview可以。这是重现代码。@interfaceMyViewController:UIViewController{UIView*subview;}@implementationMyViewController-(id)init{self=[superinit];if(self){self.view.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutor

ios - CollectionView 数据源在使用 UICollectionViewController 时不起作用,但在将 UIViewController 与 CollectionView 一起使用时起作用

我正在对UICollectionView进行子类化,并处理它的dataSource。我在CollectionView的init阶段将dataSource分配给self。importFoundationimportUIKitclassCollectionViewSubclass:UICollectionView,UICollectionViewDataSource{publicoverrideinit(frame:CGRect,collectionViewLayoutlayout:UICollectionViewLayout){super.init(frame:frame,collect

ios - 如何从 iOS Swift 3 中的 XIB 以编程方式推送和呈现给 UIViewController

我正在使用swift3.0开发一个项目,我使用以下机制从一个UIViewController导航到另一个。ifletviewController=UIStoryboard(name:"Main",bundle:nil).instantiateViewController(withIdentifier:"MP3ViewController")as?MP3ViewController{viewController.mediaDetails=mp3Detailsifletnavigator=navigationController{navigator.pushViewController(v

ios - 快速获取 UIViewController 的类名

如何在Swift中获取UIViewController类的类名?在Objective-C中,我们可以这样做:self.appDelegate=(shAppDelegate*)[[UIApplicationsharedApplication]delegate];UIViewController*last_screen=self.appDelegate.popScreens.lastObject;if(last_screen.class!=self.navigationController.visibleViewController.class){//.......}但在Swift中我试过

ios - 在 Swift 中为 UIViewController 自定义初始化,在 Storyboard 中设置界面

我在为UIViewController的子类编写自定义init时遇到问题,基本上我想通过viewController的init方法传递依赖关系,而不是直接设置属性,如viewControllerB.property=value所以我为我的viewController定制了一个init并调用了super指定的initinit(meme:Meme?){self.meme=memesuper.init(nibName:nil,bundle:nil)}ViewController界面驻留在Storyboard中,我还将自定义类的界面作为我的ViewController。并且Swift需要调用这

iphone - UIViewController 作为单例

我在标签栏应用程序中有一个UIViewController。我已经从MainWindow.nib文件中添加了Controller(即不是以编程方式)。我的问题是如何使我的ViewController成为单例?(解决Facebook委托(delegate)问题)。 最佳答案 您可能想让您的“Facebook连接代码”成为单例(或应用程序委托(delegate)的一部分),而不是ViewController本身。然后只需将FB事物与任何需要它的ViewController连接起来即可。 关于