logo
down
shadow

Perform segues when I want


Perform segues when I want

By : Becky Barry-Eisen
Date : December 05 2020, 12:22 PM
I hope this helps . You should implement shouldPerformSegue instead of checking pickerView.numberOfRows(inComponent: 0) > 0 in your prepareForSegue method.
P.S: Swift 3 Code (I assume that this is what you want).
code :
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
        return pickerView.numberOfRows(inComponent: 0) > 0
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "searchImages" {
            let controller = (segue.destination) as! WebViewController
            //replacing " " with "+" for google search queries
            let type: WebViewController.SearchType = .image
            let queryString = String(nameLabel.text!.characters.map {
                $0 == " " ? "+" : $0
            })
            controller.searchType = type
            controller.queryString = queryString
            print("2")

        }

        if segue.identifier == "searchWiki" {
            let controller = (segue.destination) as! WebViewController
            //replacing " " with "+" for google search queries
            let type: WebViewController.SearchType = .wiki
            let queryString = String(nameLabel.text!.characters.map {
                $0 == " " ? "+" : $0
            })
            controller.searchType = type
        }
    }


Share : facebook icon twitter icon
Managing two UITableViews to perform different segues

Managing two UITableViews to perform different segues


By : yStryker
Date : March 29 2020, 07:55 AM
With these it helps Instead of ctrl + drag from your cell to your destination viewcontrollers, ctrl + drag from your view controller.
Then, in your
code :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //... do other regular stuff

    if (pushingOneDestController) {
        [self performSegueWithIdentifier:@"activos" sender:cell];
    }
    else (pushingAnotherDestController) {
        [self performSegueWithIdentifier:@"arquivados" sender:cell];
    }
}
Perform different segues using switchCase

Perform different segues using switchCase


By : cryano00111
Date : March 29 2020, 07:55 AM
this will help I have an UIPickerView with 5 different objects and also a button. When I push the button, I want to go to the next ViewController. , do something like this...
code :
-(IBAction)btnClickMethod:(id)sender
{
    NSString *identifier;
    switch(cases)

       case 0:
           identifier=@"abc";  //set this identifier as per your case and condition
           break;

       case 1:
           identifier=@"def"; //set this identifier as per your case and condition
           break;

       default
           identifier=@"ghi" //set this identifier as per your case and condition
           break;

     [self performSegueWithIdentifier:identifier sender:sender];
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"abc"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
    }
if ([[segue identifier] isEqualToString:@"def"])
    {
        // Get reference to the destination view controller
        YourViewController *vc = [segue destinationViewController];

        // Pass any objects to the view controller here, like...
        [vc setMyObjectHere:object];
    }
Working with Multiple Segues | How to use Cell data to perform specific Segues

Working with Multiple Segues | How to use Cell data to perform specific Segues


By : smp858
Date : March 29 2020, 07:55 AM
it fixes the issue Assuming the items in your collection view can be re-arranged (or might be some time in the future), the indexPath will not be sufficient to give you the information which cell was selected. Thus, IMO your idea to give the cell a property is a feasible one.
The easiest "quick and dirty" way is to simply hardcode the segue identifier string into your cell. This is not the best design because you are introducing dependencies between app elements that should know of each other.
code :
class MyCell : UICollectionViewCell {
    var segue = "DefaultSegue"
}
self.performSegueWithIdentifier(cell.segue, sender:cell)
enum Segue : String {
   case ToInfo  = "SegueToInfo"
   case ToLogin = "SegueToLogin"
   // etc.
}
Is it possible to perform 2 different segues on the click of 1 button?

Is it possible to perform 2 different segues on the click of 1 button?


By : Ben Anderson
Date : March 29 2020, 07:55 AM
wish help you to fix your issue First, go drag segue from your initial view to another view, and give an identifier for that connection. Then just use code below, with different identifier names you declare at first. Like "segueToView1" to first view and "segueToView2" to another. And remember to use if else to know which view you are going
code :
performSegue(withIdentifier: "identifierName", sender: self)
How to perform differently from different segues?

How to perform differently from different segues?


By : E Webb
Date : March 29 2020, 07:55 AM
may help you . Similar to Mr.UB's answer you could also create a variable which stores the string value of the segue:
code :
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "FirstSegue"{
        let viewController = segue!.destinationViewController as! BController 
        viewController.sourceSegue = "FirstSegue"
    }
    if segue.identifier == "SecondSegue"{
        let viewController = segue!.destinationViewController as! BController 
        viewController.sourceSegue = "SecondSegue"
    }
}
var sourceSegue: String!

if sourceSegue == "FirstSegue"{
    // do something
} else if sourceSegue == "SecondSegue"{
    // do something
}
Related Posts Related Posts :
  • Change class variables in function has no effect after exiting in Swift
  • Call sent to two reciever with different userId
  • TKChartDataPoint does not conform to expected type Sequence
  • IOS/Swift - Instance member 'app' cannot be used on type ERROR
  • Create show Case view In Tabbar xcode
  • Create IOS App with Cordova on Windows10
  • Get parent process information at runtime on iOS application
  • Destination attribute mapping not showing newly added attribute in xcmodelmappingmodel while Coredata migration
  • How to convert string to NSArray in iOS
  • Converting all Realm Objects to Dictionary at once
  • How to use DACircularProgressView in swift3?
  • Stop Core Data calculation?
  • issue and crash after deletion of last row
  • Multiple UNUserNotifications not firing
  • Drawing a rectangle under text on image Then save
  • auto adjust custom UITableViewCell and Label in it to the text
  • Only use pictures taken through the camera, iOS/Swift
  • UITableView objective-c not populating correctly
  • UNNotification: Custom Sound for LocalNotification is not playing in iOS10
  • Alamofire: How to download zip files sequentially within UITableView
  • iOS Google Tag Manager Integration: How to add multiple containers per App environment?
  • I am getting Exe_Bad_Access(code=1 address=0X38) when I am integrating the CCAvenue Payment Gate way in IOS
  • iOS How to set background image for text in UILabel/UITextView?
  • Notification localization is not working in iOS 10
  • how to show multiple lines in MKAnnotation with autolayout?
  • iOS Provisioning Profile Renewal Process with MDM
  • UITextView check whether text field is empty or not in Objective-C
  • How to open Add Contact form through app
  • Is there a way to recognize, that the app was installed thru firebase dynamic link in didFinishLaunchingWithOptions?
  • iOS - Support ipv4 only API
  • Get IndexPath Value in UICollectionViewCell Class
  • 2d NSArray with enumerated types in objective-c
  • Return the bool statement directly VS using if to return bool
  • Touch ID: Biometry is locked out. Code=-8
  • Values are not updating in my text label from api calling
  • how to manage Height of UITableHeaderView in based on webview content using auto layout
  • viewDidLoad vs ViewWillAppear in IOS
  • Presenting a detail view controller from a map annotation in swift 3?
  • What is industry standard for when to push/pull between core data and remote database
  • Error when moving objects between NSMutableArray
  • Assigning values to class instance from json output
  • Does Facebook SDK support Swift 2.3/3.0?
  • google maps iOS SDK: custom icons to be used as markers
  • Difficulty reading UserDefaults with Fastlane Snapshot
  • Find individual load time of Dynamic Libraries to identify which library consumes more time to load in IOS
  • Can I add local and remote notifications in my iMessage extension?
  • UIImage goes where i tap (But i need it so you can ONLY drag it)
  • How to handle launch options in Swift 3 when a notification is tapped? Getting syntax problems
  • Mismatched colors on UINavigationBar and UISearchBar
  • iOS app that collects data from "Accu-Chek Aviva Connect" BG meter. (Bluetooth Low Energy)
  • How to make a Sprite node spin when a user taps the screen? Swift 3
  • React Native (iOS) app loads nicely on wifi; crashes on LTE/cell
  • How to use GADRewardBasedVideoAd
  • Get game request ID / Access Facebook game request notification content
  • Error opening shared document via CloudKit
  • SKPhysicsJointLimit has a elastic behaviour, but i need a strong rope simulation
  • Handing a response in a controller after segueing to another controller
  • Alamofire request gets stuck when entering background?
  • iOS swift: App Transport Security has blocked a cleartext HTTP (http://) resource
  • Full Screen layout for in Xcode 8
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com