草庐IT

UIViewController_keyboard

全部标签

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需要调用这

C++ SetWindowsHookEx WH_KEYBOARD_LL 正确设置

我正在创建一个控制台应用程序,我想在其中记录按键操作(例如向上箭头)。我创建了一个低级键盘Hook,它应该捕获任何线程中的所有按键并调用我的回调函数,但它不起作用。当我按下一个键时,程序会暂停一点,但从不调用回调。我检查了文档,但没有找到任何东西。我不知道是我使用的SetWindowsHookEx()不正确(据我所知它成功创建了钩子(Hook))还是我的回调函数不正确!我不确定怎么了!预先感谢您的帮助。#include"Windows.h"#includeusingnamespacestd;HHOOKhookHandle;LRESULTCALLBACKkeyHandler(intnCo

iphone - UIViewController 作为单例

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

ios - ARC - 当 UIViewController 设置为 nil 时,是否处理手势识别器和 KVO?

我的问题很简单:当UIViewController设置为nil时,手势识别器和KVO是否被清除?我有一个项目,用户可以在其中创建和删除一些复杂的基于UIViewController的实例。这些存储在NSMutableArray中。如果我只是从数组中删除实例,然后将其设置为nil(我猜这是多余的),实例的所有@properties都会被清除吗(假设没有其他对它们的引用)?编辑当我不管理KVO时,我会收到下面的警报(错误)——所以我想答案是“否”Aninstance0xce26d40ofclassTrackwasdeallocatedwhilekeyvalueobserverswerest

ios - UIViewController 未收到 touchesBegan 消息

我的UIViewController中有一个UIScrollView。我需要检测对它的任何触摸,然后做一些事情。我还需要什么?-(BOOL)canBecomeFirstResponder{returnYES;}-(void)viewDidAppear:(BOOL)animated{[superviewDidAppear:animated];[selfbecomeFirstResponder];}-(void)touchesBegan:(NSSet*)toucheswithEvent:(UIEvent*)event{NSLog(@"TOUCHED");//neverhappensfor(