uiviewcontroller

Is it ok to create a UIView on a background thread?

孤人 提交于 2019-12-28 05:58:49
问题 I know UIView are not thread safe so i cant add a view on a background thread, to work around this is it ok to create a UIView on a background thread then add it on the main thread? Note: the reason im not doing this on the main thread is because my actual code is a lot more complex and therefor takes a while to create all the views and fill the values. I dont want the UI to become un-responsive when I do this so im trying to work around this. for example.. -(void)addLabel//called on

iOS: What is the difference between -init and -viewLoad of a ViewController?

自作多情 提交于 2019-12-28 05:37:06
问题 I don't know exactly what's the right place to set things like the tintColor of the NavigationBar or the title of my ViewController. It works in the -init method and the -viewLoad method too. What is the "best-practice" or "right way" to do this? Has one of those any advantages? 回答1: The init methods (yes there is more then one) are where the UIViewController is initialized. Thus this is the place where you do stuff for the UIViewController and not its views. If you use a nib to load you view

Navigation Controller Loop

♀尐吖头ヾ 提交于 2019-12-28 04:29:11
问题 I'm making an app which has a shopping cart feature. The shopping cart VC is accessible from several VCs via a button on the navigation bar. So far I only have one Navigation Controller and as shown in the image, each VC takes me to the next one, nothing fancy. The 3rd VC (blue arrow pointing to) is a VC that shows the product/item's details and enables me to add it to the cart. Problem comes with the Shopping Cart VC. To edit the item, I'd like to re-use the same product/item's details (blue

How to loop through Outlets of a UIViewController with Swift

时间秒杀一切 提交于 2019-12-28 04:21:11
问题 I'm wondering, if it's possible to loop through all outlets of a UIViewController with swift. Specificly, I want to check if every textfield is filled by the user. 回答1: This is what Outlet Collections are for. Drag all your textfields in the same Outlet Collection in InterfaceBuilder and create an @IBOutlet to that collection in your class file: To create the outlet collection in InterfaceBuilder, ctrl-drag from the first UITextField to your class file in the assistant editor. Then choose

this class is not key value coding-compliant for the key XXXXXX

萝らか妹 提交于 2019-12-28 03:11:47
问题 when i try to build and run my app, it crashes and i got this in the log : reason: '[<LoadingViewController 0x6b2c5a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key aproposViewController.' the strange is that aproposViewController is not used in LoadingViewController , it's just another view controller in my app. please help, thx in advance :) EDIT appdelegate.h : @class LoadingViewController; @interface TopStationAppDelegate : NSObject

How to implement UIPageViewController that utilizes multiple ViewControllers

孤人 提交于 2019-12-27 19:10:10
问题 I've been working on a simple test app to learn the ins and outs of the UIPageViewController. I have it working but I'm not convinced my execution is the best way. I hope some of you can point me in the right direction. To get a basic understanding I used this tutorial as a starting point. http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ The tutorial creates an app that uses one viewController for each of the pages presented by the UIPageViewController . However I need to

iPhone Landscape FAQ and Solutions

删除回忆录丶 提交于 2019-12-27 12:54:06
问题 There has been a lot of confusion and a set of corresponding set of questions here on SO how iPhone applications with proper handling for Landscape/Portrait mode autorotation can be implemented. It is especially difficult to implement such an application when starting in landscape mode is desired. The most common observed effect are scrambled layouts and areas of the screen where touches are no longer recognized. A simple search for questions tagged iphone and landscape reveals these issues,

Custom Animation for Pushing a UIViewController

和自甴很熟 提交于 2019-12-27 10:29:50
问题 I want to show a custom animation when pushing a view controller: I would like to achieve something like an "expand" animation, that means the new view expands from a given rectangle, lets say [100,100 220,380] during the animation to full screen. Any suggestions where to start, respectively any documents, tutorials, links? :) Alright. I could make the expand animation with the following code: if ([coming.view superview] == nil) [self.view addSubview:coming.view]; coming.view.frame =

UIViewController的生命周期

蹲街弑〆低调 提交于 2019-12-26 19:12:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> UIViewController 是IOS程序中的一个重要组成部分,扮演者一个大管家的身份,管理着程序中的众多视图: 何时加载view,加载的原则是什么,视图何时消失等问题,文档中讲的都很详细。   Controller的view最好在需要显示时再去加载,并且在系统发出内存警告时释放不必要的view及相关的可再生的数据对象。 一、UIViewController的初始化   初始化时会根据需要调用init,initWithCoder等相关函数,这个时候我们可以做一下简单的初始化操作,建立ViewController中需要使用的数据模型等,不建议在初始化阶段就直接创建view及其他与显示有关的对象(应该放到loadView的时候去创建,或者采用懒加载的方法创建)。   我们都知道ViewController可以通过代码和xib两种方式创建,这两种方式的初始化流程也不尽相同。   1)使用xib创建的VC   xib其实最终是会把我们的设置保存成一个 数据集(xml文件) ,当需要初始化构建VC的时候,回去读取记录的数据集,然后帮我们动态的创建VC,因此可以想象它在初始化时会先去找看是否实现initWithCoder方法,如果该类实现了该方法,就直接调用initWithCoder方法创建对象

Timer to return to previous view in xcode [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-25 19:36:45
问题 This question already has an answer here : Revert to previous controller after xx amount of seconds (1 answer) Closed 5 years ago . Hello I am extremely new to xcode and programming in general. I am trying to create a simple app that has two view controllers. The first ViewController in the story board has no code only a navigation bar and a next button which has a modal connecting to VideoController. I have added this code to the VideoController.m file - (void)viewDidLoad { [super