logo
down
shadow

How to trigger UIButton from another class?


How to trigger UIButton from another class?

By : mrPib
Date : November 18 2020, 01:01 AM
it fixes the issue I have two view controllers linked by button1. viewController1 contains button1. viewController2 is triggered by button1. viewController2 contains button2. How can I trigger button2 from button1? , You can do it programmatically by writing this:
code :
[_button sendActionsForControlEvents:UIControlEventTouchUpInside];


Share : facebook icon twitter icon
Why can I not use UIButton to trigger a dismissModalViewController?

Why can I not use UIButton to trigger a dismissModalViewController?


By : user2131331
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You should try running with the zombies instrument to see where you are messaging a freed object. From Xcode just go to Run->Run with Performance Tool->Zombies and that will launch Instruments with the correct setup.
You are probably either releasing (or autoreleasing) an object you shouldn't (because you don't own it) or are failing to retain something that you should. Instruments will help you find out where.
How could a disabled UIButton trigger another event?

How could a disabled UIButton trigger another event?


By : น่ารัก จังเลยเธอ
Date : March 29 2020, 07:55 AM
it should still fix some issue Not saying it's good design (I agree with the commenters who say that a tap on a disabled button shouldn't do anything), but you could attach a UITapGestureRecognizer to the parent view, and when the gesture comes in, check to see if the tap is within the bounds of the disabled view.
Taps on the disabled button will fire a UITapGestureRecognizer that's attached to the button's superview.
code :
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
[self.view addGestureRecognizer:tapRecognizer];
- (void)viewTapped:(id)sender {
    UITapGestureRecognizer *recognizer = (UITapGestureRecognizer *)sender;
    CGPoint pt = [recognizer locationOfTouch:0 inView:self.testButton];
    if (CGRectContainsPoint(self.testButton.bounds, pt)) {
        NSLog(@"Disabled button tapped");
    }
}
I subclassed UIButton in MonoTouch but underlying ObjC class is still UIButton

I subclassed UIButton in MonoTouch but underlying ObjC class is still UIButton


By : Wubidof
Date : March 29 2020, 07:55 AM
it helps some times Turns out, I had to call the parameterless UIButton constructor, and not the one I was calling.
Removing : base (UIButtonType.Custom) from constructor defnition was enough to make it work:
code :
public BackButton (string text, EventHandler handler)
     // : base (UIButtonType.Custom) -- remove this line
{
    TouchUpInside += handler;
    SetTitle (text, UIControlState.Normal);
}
public UIButton (UIButtonType type) : base (
    Messaging.IntPtr_objc_msgSend_int (UIButton.class_ptr,
        UIButton.selButtonWithType_, (int)type)
    ) { }
Swift: Custom UIButton Class in View Controller Touch Event Not Trigger?

Swift: Custom UIButton Class in View Controller Touch Event Not Trigger?


By : Phil Jee
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I created a custom UIButton class as so: , You may need a closure not a computed property
code :
lazy var customBtn: CustomButton = {
    let frame = CGRect(x: 48.0, y: 177.0, width: 80.0, height: 40.0)
    let custom = CustomButton(frame: frame, title: "Test",alignment: NSTextAlignment.right)
    return custom
}()
customBtn.addTarget(self,
                        action: #selector(touchCancel),
                        for: .touchUpInside)
Subview of custom UIButton class doesn't trigger click

Subview of custom UIButton class doesn't trigger click


By : Willem Prinsloo
Date : March 29 2020, 07:55 AM
may help you . I figured out how to do it! If "bg" is the subview I'm adding to the UIButton, then you should do:
Related Posts Related Posts :
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • webview not showing on full Screen of iphone 6
  • Location Notification's based on Latest iOS Feature
  • Adjusting Height of UITableViewCell
  • How to show five digit unicode in iphone
  • unwind doesn't work
  • Confusion about coordinates, frames & child nodes in SpriteKit on iOS?
  • If Statements not being recognized by Xcode
  • readonly property in RubyMotion
  • 'No available types for source 1' when the app runs on my device(IPhone 6) swift
  • IOS:Remove view when clicked in background
  • Removing "\" from URL in iOS Swift
  • iOS - Send an email automatically (NOT from user's account)
  • The usage of NSNotificationCenter in the relationship of parent and children
  • When do Apple auto-renewable subscriptions renew?
  • Unknown large spacing between x-axis label and base of plot in core-plot
  • How do I change the displayed time format after NSTimer is initiated?
  • Swift JSON breaks when [ ] are used
  • Secure Memory For Swift Objects
  • didSelectItemAtIndexPath doesn't work normally
  • Swift Documentation Comments
  • Is there a simple way to assign a value only once(first time) inside a loop/repeatedly running method?
  • Play sound in while app in background
  • If I have an embedded unrestricted webview, does that mean I have third-party content?
  • UITapGestureRecognizer on UIScrollView
  • App does not respond to hardware volume changes on iPad
  • troubleshoot asp.net web app on iOS
  • What size should my tab bar item icons be?
  • Parse.com Facebook authorize never calls completion handler
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org