Swift How to add the shouldReceiveTouch on Switch?
Please try to use this line
let newSwitch: UISwitch!
instead of
var newSwitch: UISwitch!
UISwitch not reaction
You have created ViewController, but not presented it. So loadView was never called and yours .switch is nil.
try this:
ViewController *vc = [[[ViewController alloc] init] autorelease];
[self presentViewController:vc
animated:YES
completion:^(){
vc.switch.on = variable;
}];
iOS - indexPathForRowAtPoint don't return correct indexPath with different cell height
One way to do it would be to add a UILongPressGestureRecognizer to each UITableViewCell (that all use the same selector), then when the selector is called you can get the cell via sender.view. Perhaps not the most memory efficient, but if the single gesture recognizer won't return the right row in certain situations, this way should work.
Something like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPress:)];
[longPress setMinimumPressDuration:2.0];
[cell addGestureRecognizer:longPress];
[longPress release];
return cell;
}
then
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
UITableViewCell *selectedCell = sender.view;
}
Related Topics
How to Synchronize Access to a Property That Has Didset
Do Not Copy Swift Libraries with Xcode 8
Setadvertisertrackingenabled Is Not Found in Settings Class of Fbsdk
[Core Data]: Threw While Encoding a Value. with Userinfo of (Null)
Swift 3 Custom Extension of Ns Measurement? Ex. Sheeps to Goats
Pass Custom Parameter to UIbutton #Selector Swift 3
Swift Textview Align with English and Arabic Languages
Parse Migration Error to Mlabs and Heroku
Swift Error "Static Member Cannot Be Used on Instance of Type"
Why Do I Get Rgb Values of (0,0,0) for an Nsimage with a Transparent Background
Reduce Float Precision Using Regexp in Swift
Appdelegate#Applicationdidfinishlaunching Not Called for Swift 4 Macos App Built from Command Line
Cannot Authenticate User for Aws Appsync with Swift Sdk
Can Not Get Correct Position of View in Swiftui
Flattened Objects in JSON File to Nested Object Structure in Swift
How to Make First Responder in Swiftui Macos
Using a Timer in The Background Thread to Update UI
Error: Variable with Getter/Setter Cannot Have an Initial Value