viewcontroller

How to make cells have a gradient background?

假装没事ソ 提交于 2019-12-18 07:07:02
问题 I have inserted a table view on my view controller and I was wondering how can I give the cells in the table view a gradient background? Can I edit each cell individually to give it a different color gradient background for each cell? For example, each cell is labeled after an index in the trainingLevels array, how could I make to where each has a different color gradient background? Here's my code: import UIKit class ViewController: UIViewController, UITableViewDelegate,

Modal view closes when selecting an image in WkWebView iOS

狂风中的少年 提交于 2019-12-18 04:50:30
问题 I'm currently building an app with a modal view popping up that contains a WkWebView. When I want to upload an image within this modal view and the Photo Selection appears, the modal view just dismisses back to the view controller that fired it up. How can I prevent that? import UIKit class PostWindow : UIViewController { @IBAction func close(sender: AnyObject) { dismissViewControllerAnimated(true, completion: nil) } override func viewDidLoad() { super.viewDidLoad() // do stuff here let

Passing array between view controllers?

99封情书 提交于 2019-12-17 19:56:45
问题 I really need some more help! I am trying to pass an array from one view controller to another. I think the latter being a 'child' view controller? My code is as follows: MainViewController.h: #import <UIKit/UIKit.h> #import <AudioToolbox/AudioToolbox.h> #import <AVFoundation/AVFoundation.h> @interface HelloWorldIOS4ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, AVAudioPlayerDelegate> { NSMutableArray *countProductCode; UIPopoverController

Pass Variables to a new View Controller via a Subclass and Dozens of Map Pins

余生长醉 提交于 2019-12-17 17:14:14
问题 I have a few moving parts in this one that I can't seem to stitch together, hopefully it is pretty straightforward. Previous questions don't use a subclass and in this example there could be dozens of custom pins on the map and each pin passes specific variables to a new ViewController Three Goals: Add image to custom annotation (see code below) I have a subclass named Capital , I would like to add the image in #1 and then create additional variables to hold values that will be passed to a

presenting ViewController with NavigationViewController swift

旧街凉风 提交于 2019-12-17 15:19:58
问题 I have system "NavigationViewController -> MyViewController", and I programmatically want to present MyViewController inside a third view controller. The problem is that I don't have navigation bar in MyViewController after presenting it. Can you help me? var VC1 = self.storyboard.instantiateViewControllerWithIdentifier("MyViewController") as ViewController self.presentViewController(VC1, animated:true, completion: nil) 回答1: Calling presentViewController presents the view controller modally ,

In iOS, how to drag down to dismiss a modal?

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:16:06
问题 A common way to dismiss a modal is to swipe down - How do we allows the user to drag the modal down, if it's far enough, the modal's dismissed, otherwise it animates back to the original position? For example, we can find this used on the Twitter app's photo views, or Snapchat's "discover" mode. Similar threads point out that we can use a UISwipeGestureRecognizer and [self dismissViewControllerAnimated...] to dismiss a modal VC when a user swipes down. But this only handles a single swipe,

How do I detect user inactivity in Swift? [duplicate]

南楼画角 提交于 2019-12-14 03:38:08
问题 This question already has answers here : How to detect user inactivity since last touch on a particular viewcontroller in iOS? (2 answers) Closed 4 years ago . I need to implement an Idle Time Out feature. To do that I simply need to know how to detect when the user touches the screen (something similar to onUserInteraction method used in Android). So how can I simply discover when the user interacts with the ViewController? P.S: if I ask this it is because you can't find nothing good in the

Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'

回眸只為那壹抹淺笑 提交于 2019-12-14 03:33:16
问题 Wanna pass data from a ViewController which has TableView init, to another ViewController. But it's showing me the error "Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)' " @IBOutlet weak var completedCaseTableView: UITableView! override func viewDidLoad() { super.viewDidLoad() completedCaseTableView.delegate = self completedCaseTableView.dataSource = self // Do any additional setup after loading the view. } public func numberOfSections(in tableView: UITableView) -> Int {

Using the value of a variable of a viewcontoller from another viewcontroller

十年热恋 提交于 2019-12-14 03:05:48
问题 I want to use the value that I received after tapping a UITableCellView. I stored the value into arrays, and defined the instance of the ViewController of UITableCellView in order to reach those arrays. Even though I can reach the arrays from the other ViewController, it always write "0" as a result to the textfield I want to have the data. I need the exact data stored in the array. Here is the code how I tried to do it; (fourthViewController) - (void)tableView:(UITableView *)tableView

Adding a ViewControllers's view as subView

别说谁变了你拦得住时间么 提交于 2019-12-14 01:53:43
问题 I am adding a ViewControllers view as a subView to another ViewController, Example : In FirstScreen viewcontroller i do this, [self.view addSubview:self.secondScreen.view]; And Once i remove it from FirstScreen i do this [self.secondScreen.view removeFromSuperView]; self.secondScreen=nil; But While Adding the subView ViewDidLoad method is called but while removeFromSuperView ViewDidUnLoad is not called. My Question 1) will all my objects in my secondScreen will get deallocated once i set the