viewcontroller

UIScrollView prevents touchesBegan, touchesMoved, touchesEnded on view controller

随声附和 提交于 2019-12-28 05:31:47
问题 I am handling touches for a couple of my UI components in my view controller (custom subclass of UIViewController). It has methods touchesBegan:withEvent: , touchesMoved:withEvent: , and touchesEnded:withEvent: . It was working fine. Then I added a scroll view (UIScrollView) as the top view in the hierarchy. Now my touch handlers on the view controller don't work. They don't get called. The interesting thing is, I have various other UI components within the scroll view that do work. Some are

ViewController的生命周期分析和使用

允我心安 提交于 2019-12-26 18:42:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 作者 shenqiliang 发布在 2012年3月20日 下午8:11 iOS的SDK中提供很多原生ViewController,大大提高了我们的开发效率,下面是我的一些经验。 一、结构 按结构可以对iOS的所有ViewController分成两类: 1、主要用于展示内容的ViewController,这种ViewController主要用于为用户展示内容,并与用户交互,如UITableViewController,UIViewController。 2、用于控制和显示其他ViewController的ViewController。这种ViewController一般都是一个ViewController的容器。如UINavigationController,UITabbarController。它们都有一个属性:viewControllers。其中UINavigationController表示一种Stack式结构,push一个ViewController或pop一次,因此后一个ViewController一般会依赖前一个ViewController。而UITabbarController表示一个Array结构,各个ViewController是并列的。 第一种ViewController会经常被继承

Why instantiateViewContoller is necessary?

一笑奈何 提交于 2019-12-25 08:48:38
问题 Why can't I create the view controller objects using sth like resultVC = ResultViewController() instead of the following way. let storyboard = UIStoryboard (name: "Main", bundle: nil) let resultVC = storyboard.instantiateViewController(withIdentifier: "ResultViewController") as! ResultViewController // Communicate the match resultVC.match = self.match self.navigationController?.pushViewController(resultVC, animated: true) 回答1: Everything is depends on your logic. There are three basic ways by

ios 8.1: Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource'

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 04:12:27
问题 I'm getting the following error when compile swift application (iOS 8.1) Type 'ViewController' does not conform to protocol 'UICollectionViewDataSource' at "class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate" line I've just checked few posts here but no one helps me to solve this problem. Here's the code of ViewController.swift file: import UIKit class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { var

if my “button” is selected on view controller 1, then image should then display and stay on view controller 2

最后都变了- 提交于 2019-12-25 03:45:29
问题 If the "button/checkbox" I have created below is selected by the user on view controller 1, then I would like an image to (appear) display on view controller 2. if i leave view controller 2 screen and come back to view controller 2 screen, the image should still display as long as the button is still selected on view controller 1. if the "button" is no longer selected on view controller 1, then the image should no longer be displayed on view controller 2. Please note that the "button/checkbox

If statement based on whatever the previous view controller was

无人久伴 提交于 2019-12-25 03:38:45
问题 Here is what I go so far: - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (preivousViewController isEqualToString:@"...") { if ([self.filteredArray count] == 0) self.person = self.users[indexPath.row]; else self.person = self.filteredArray[indexPath.row]; self.mugshot = cell.imageView.image; [self performSegueWithIdentifier:@"SelectPerson" sender:self]; } else { if ([self

swift - adding values between 2 view controllers by prepareforsegue

十年热恋 提交于 2019-12-25 02:54:01
问题 I have 2 ViewControllers: ViewController1, ViewController2. An "Add" button in ViewController1 will bring up ViewController2. User will then enter in values into ViewController2 which will then be passed back into ViewController1 by prepareforsegue. These values are then append onto the properties of type array in viewcontroller1. This is being repeated, whereby the user continue pressing the add button to bring up ViewController2 from ViewController1, and then add in new values to be

segue shrinks viewcontroller. how to keep “normal” size

旧巷老猫 提交于 2019-12-24 19:53:10
问题 Setup embedded viewcontroller tabs using UISegmentedControl and embedded ViewControllers (as in this example: https://ahmedabdurrahman.com/2015/08/31/how-to-switch-view-controllers-using-segmented-control-swift/) Its all good. The tabs work. The UI changes. BUT, when I touch a button in one of the embedded VC's then I want to launch yet another ViewController ("Z". Simple enough? NO! In Interface Builder, when I add the segue to the "Z" controller then IB automatically resizes it in the

Linking View Controllers through button

北慕城南 提交于 2019-12-24 15:12:32
问题 I'm a beginner at all of this...Having said that I've come across a point in my app where I've stalled and don't know what to do or fix next. So any answers would be appreciated! So in my Home View Controller, I have four buttons with four different categories. Each of these categories has its own question list, but they have a common "General Question" list. The general question list has its own view controller. When you click on any of the four buttons, it brings you to the General Question

Stopping ScrollView Going Above & Below The Bounds

人盡茶涼 提交于 2019-12-24 14:28:42
问题 I created a UIScrollView in a ViewController and added UIView & UITableView as siblings of ViewController. var pageSize = view.bounds.size // MiniQuestion: I disabled vertical indicators but it caused a gap for the width // of the indicator, so I added the gap manually. Is it okay behaviour? pageSize.width += 5 MyView.backgroundColor = UIColor.redColor() MyTableView.backgroundColor = UIColor.blueColor() let pagesViews = [MyView , MyTableView] let numberOfPages = pagesViews.count for